Is there a way to create anonymous structs in C#?

TheHolyTerrah picture TheHolyTerrah · Feb 15, 2010 · Viewed 10.5k times · Source

There doesn't seem to be any way as anonymous types derive from object. But I thought I'd ask since much of the time we use anonymous types in simple query expressions to extract subsets of data to be used in those anonymous types we create. It just seems to me they should be structs (value types) for greater memory efficiency vs. reference types.

Thoughts?

Answer

JaredPar picture JaredPar · Feb 15, 2010

No there is no supported C# syntax which will produce anonymous structs