Skip to content

Instantly share code, notes, and snippets.

@syedharoonmca
Last active December 5, 2022 04:30
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/02191e28c162e0739a4662ea8e5fdc13 to your computer and use it in GitHub Desktop.
Save syedharoonmca/02191e28c162e0739a4662ea8e5fdc13 to your computer and use it in GitHub Desktop.
LINQ Method Syntax
using System;
using System.Collections.Generic;
using System.Linq;
namespace LINQDemo
{
class Program
{
static void Main(string[] args)
{
//Data Source
List<int> integerList = new List<int>()
{
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
};
//LINQ Query using Method Syntax
var MethodSyntax = integerList.Where(obj => obj > 5).ToList();
//Execution
foreach(var item in MethodSyntax)
{
Console.Write(item + " ");
}
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment