Wednesday 19 August 2015

What is Collection Initializer 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