Created
May 26, 2019 21:23
-
-
Save cagdaskarademir/c1631dbdd5ec6d0081f04bcab9741bdd to your computer and use it in GitHub Desktop.
GetNth Method
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
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