Is this possible?
For example, if I have
List<Item> myList = new List<Item>;
//added 100 of Items to myList
//then I want to grab items at indices 50 - 60
List<Item> myNewList = myList.?
How do I do that w/o looping through myList? Thank you.
The IndexOf method returns the first index of an item if found in the List. C# List<T> class provides methods and properties to create a list of objects (classes). The IndexOf method returns the first index of an item if found in the List.
They are 0 based. Count will start with one however if the list has any items in it.
There is a method that retrieves these items, List.GetRange. http://msdn.microsoft.com/en-us/library/21k0e39c.aspx
List<Item> myList = new List<Item>;
myList.GetRange(50, 10); // Retrieves 10 items starting with index #50
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With