Friday 12 April 2013

What is the collections Initializers in .Net


Which allows to initialize a collection also at the time of it’s declaration similar to array which was not possible in the earlier version
Before 3.0 :-
               List<int> li = new List<int>();
               Int[] arr={ 10,20,30,40,50,60};
               li.addRange(arr);
From 3.0 :-
               List<int> li = new List<int> { 10,20,30,40,50,60};

No comments:

Post a Comment