Advertisement
Fhernd

VT2.16-Generar-n-ésimo-elemento.linq

Feb 26th, 2017
38,965
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.37 KB | None | 0 0
  1. int n = 20;
  2.  
  3. List<int> serie = Enumerable.Range(1, 100).ToList();
  4.  
  5. List<int> nesimosElementos = new List<int>();
  6.  
  7. Enumerable.Range(0, serie.Count() / n)
  8.     .ToList()
  9.     .ForEach(
  10.         indice =>
  11.         {
  12.             nesimosElementos.Add(serie.Skip(indice * n).First());
  13.         }
  14.     );
  15.    
  16. nesimosElementos.Dump("20-ésimos Elementos de la Serie 1-100");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement