linq - Question about a terminology which implements something like this list.Add(new{a=1, b=2}) -


what terminology usage of "new" in:

 list.add(new{a=1, b=2}) 

and type should replace t in list getlist if want use list returned value? don't want replace t "object" because want parse in linq query.

thanks.

since did not specify type: new {1), it's called object initializers anonymous types. (msdn explaining them) object initializer part { a=1, b=2}.

if want able reference type, have create type , stuff values in.

list.add(   new mytype() {          a=1,           b=2   });  

if going pairing 2 items using pair class. there triplet class in case might want store 3 items.


Comments

Popular posts from this blog

unicode - Are email addresses allowed to contain non-alphanumeric characters? -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

c++ - Convert big endian to little endian when reading from a binary file -