Skip to content

Commit

Permalink
# returning multiple values with tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
nahiandev committed Dec 4, 2024
1 parent 37d4fd8 commit 02dd6a6
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions DomeTrain/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,23 @@
class Program
{
static void Main()
{
List<int> nums = [1, 2, 3, 4, 5, 7, 2, 43, 65, 7, 6, 23,
543, 6, 57, 54, 23, 2, 234, 643];
//var result = LambdaOps(500, 600, nums, (n, x, y) => n.Where(a => a > x && a < y)
//.ToList());
{

//result.ForEach(Console.WriteLine);
var VT = (1, 2, 3, 4, 5, "RE", 'E', true, 1.2, 1.3f);

Check warning on line 8 in DomeTrain/Program.cs

View workflow job for this annotation

GitHub Actions / build

The variable 'VT' is assigned but its value is never used

Check warning on line 8 in DomeTrain/Program.cs

View workflow job for this annotation

GitHub Actions / build

The variable 'VT' is assigned but its value is never used

const int value = 5;

var flag = ActionOps(nums, value, (n, v) => n.IndexOf(v) is not -1);
List<int> nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];

var (_, __) = MinMax(nums);

Console.WriteLine(flag);
Console.WriteLine(__);

}
private static List<int> LambdaOps(int x, int y, List<int> nums,
Func<List<int>, int, int, List<int>> operation) => operation(nums, x, y);
private static List<int> LambdaOps(int x, int y, List<int> nums, Func<List<int>, int, int, List<int>> operation) => operation(nums, x, y);
private static bool ValidateAgainstCondition(List<int> collection, int index, Func<List<int>, int, bool> expression) => expression(collection, index);


private static bool ActionOps(List<int> collection, int index, Func<List<int>, int, bool> expression) => expression(collection, index);
private static (int Min, int Max) MinMax(List<int> nums) => (nums.Min(), nums.Max());

}
}

0 comments on commit 02dd6a6

Please sign in to comment.