For a general List<T> this is the GetRange(int, int) method.
Edit: note that this is a shallow copy, not a “look” on the original. I don't think C # offers exact functionality.
Edit2: as Camarey points out, you can have read-only access:
List<int> integers = new List<int>() { 5, 6, 7, 8, 9, 10, 11, 12 }; IEnumerable<int> view = integers.Skip(2).Take(3); integers[3] = 42; foreach (int i in view )
The above text will print 7, 42, 9.
Razzie Aug 17 '09 at 11:03 2009-08-17 11:03
source share