Possible Duplicate:
Simplified Collection initialization
I have the string values, I just want to set them in a list. Something like –
List<string> tempList = List<string>();
tempList.Insert(0,"Name",1,"DOB",2,"Address");
I guess I am having a brain freeze 🙂
With the collection initializer syntax, you don’t even need the explicit calls to
Add()orInsert(). The compiler will put them there for you.The above declaration is actually compiled down to: