Boydski Boydski - 8 months ago 57
C# Question

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

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.


Answer Source

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