Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Pick every 10th element:
- int n = 10;
- // Range of numbers:
- List<int> numbers = Enumerable.Range(1,100).ToList();
- // List of nth elements:
- List<int> nthElements = new List<int>();
- // Pick every 10th element:
- Enumerable.Range(0, numbers.Count()/n)
- .ToList()
- .ForEach(k => nthElements.Add(numbers.Skip(k*n).First()));
- // Outputs the results:
- nthElements.Dump("10th elements");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement