using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace linq___
{
class Program
{
static void Main(string[] args)
{
int[] arr = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 34, 56 };
// Through Linq
var traverse = from num in arr
where num > 4
select num;
foreach (var item in traverse)
{
Console.WriteLine(item);
}
//or
var tr = arr.Where((num) => num > 4);
foreach (var item in tr)
{
Console.WriteLine(item);
}
// Through for loop
for (int i = 0; i < arr.Length; i++)
{
if (arr[i] > 4)
{
Console.WriteLine(arr[i]);
}
}
// This program is made by Jaspreet Siingh
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace linq___
{
class Program
{
static void Main(string[] args)
{
int[] arr = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 34, 56 };
// Through Linq
var traverse = from num in arr
where num > 4
select num;
foreach (var item in traverse)
{
Console.WriteLine(item);
}
//or
var tr = arr.Where((num) => num > 4);
foreach (var item in tr)
{
Console.WriteLine(item);
}
// Through for loop
for (int i = 0; i < arr.Length; i++)
{
if (arr[i] > 4)
{
Console.WriteLine(arr[i]);
}
}
// This program is made by Jaspreet Siingh
}
}
}
0 comments:
Post a Comment