[C# 3.0+] Annonymous Types
What Does it do?
var annon = new { name1 = var1, name2 = var2, ... };
// or
obj annon = new { name1 = var1, name2 = var2, ... };
// Example
obj results = new { OriginalRequest = myRequest, Data = foundData, Status = dataStatus };
// Now you can see results.Data!
Limitations
I had originally wanted to use this to pass a complex, dynamic object back from a function, however, I soon found out that this was not possible [without the use of reflection]:
From Rick Strahl’s Blog
One very important aspect to understand about anonymous types is that they are a compiler generated construct. The type is a regular .NET type similar to any other but it has one big limitation: Anonymous types are scoped only to the currently executing method. Because the generated type is anonymous there’s no public name for the type that you can access. In other words you can’t instantiate the type directly on your own and you can’t reference the type outside of the method that created it.
Tags: annonymous types

So… It’s a runtime-only association list with severe scope restrictions?
Language design fail.
Yeah, at first I thought it was a really cool concept given what I *thought* I could do with it… but then as I got further along with it I figured out I couldn’t use it like that. Now I’m not sure what it *is* useful for.