With LINQ:
List<string> l = new List<string> { "1", "2", "3" ,"4","5"}; List<string> l2 = l.Skip(1).Take(2).ToList();
If you need foreach then there is no need for ToList:
foreach (string s in l.Skip(1).Take(2)){}
The advantage of LINQ is that if you just want to skip any host element, you can:
List<string> l2 = l.Skip(1).ToList(); foreach (string s in l.Skip(1)){}
those. no need to care about quantity / length, etc.
jw_ May 02 '19 at 9:34 a.m. 2019-02-02 09:34
source share