Created
January 1, 2023 06:36
-
-
Save syedharoonmca/d83b11834281361ce316ee99ee0d19bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace LINQDemo | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
List<int> intList = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; | |
//Method Syntax | |
IEnumerable<int> filteredData = intList.Where(num => num > 5); | |
//Query Syntax | |
IEnumerable<int> filteredResult = from num in intList | |
where num > 5 | |
select num; | |
foreach (int number in filteredData) | |
{ | |
Console.WriteLine(number); | |
} | |
Console.ReadKey(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment