Skip to content

Instantly share code, notes, and snippets.

@syedharoonmca
Created January 1, 2023 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save syedharoonmca/d83b11834281361ce316ee99ee0d19bb to your computer and use it in GitHub Desktop.
Save syedharoonmca/d83b11834281361ce316ee99ee0d19bb to your computer and use it in GitHub Desktop.
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