I have used Visual Studio 2012 for debugging purpose. But you can use any version of visul studio as per your availability.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class LinqExercise
{
static void Main(string[] args)
{
List<int> list = new List<int>();
list.Add(10);
list.Add(20);
list.Add(30);
list.Add(40);
list.Add(90);
list.Add(50);
list.Add(70);
Console.WriteLine("\nThe members of the list are : ");
foreach (var lstnum in list)
{
Console.Write(lstnum + " ");
}
List<int> FilterList = list.FindAll(x => x > 20 ? true : false);
Console.WriteLine("\n\nThe numbers greater than 20 are : ");
foreach (var num in FilterList)
{
Console.WriteLine(num);
}
Console.ReadLine();
}
}
I have used Visual Studio 2012 for debugging purpose. But you can use any version of visul studio as per your availability.
Result:
The members of the list are :
10 20 30 40 90 50 70
The numbers greater than 20 are :
30
40
90
50
70
need an explanation for this answer? contact us directly to get an explanation for this answer