How are the Indexers are defined in List and Arrays.
List<MyStruct> lists=new List<MyStruct>();
where MyStruct
is a Structure. Now Consider
MyStruct[] arr=new MyStruct[10];
arr[0]
gives a reference to the first Structure item.But lists[0]
gives me a copy of it.
Is there any reason why it is done like that.
Also since Int32
is structure List<Int32> list1 =new List<Int32>();
how it is possible for me to access list1[0]
or assign list1[0]=5
where as it is not possible to do lists[0]._x=5