Skip to content

Instantly share code, notes, and snippets.

@cagdaskarademir
Created May 26, 2019 21:23
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 cagdaskarademir/c1631dbdd5ec6d0081f04bcab9741bdd to your computer and use it in GitHub Desktop.
Save cagdaskarademir/c1631dbdd5ec6d0081f04bcab9741bdd to your computer and use it in GitHub Desktop.
GetNth Method
public static class LinqExtension
{
public static T GetNth<T>(this IEnumerable<T> list, int n)
{
return list.Where((data, i) => i == n).FirstOrDefault();
}
public static T GetNth<T>(this IList<T> list, int n)
{
return list.Where((data, i) => i == n).FirstOrDefault();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment