Possible Duplicate:
Anonymous Types - Are there any distingushing characteristics?
Can't find suitable property.
if(new {a = 2, b= "z"}.GetType()...)
what to put instead of ...?
Possible Duplicate:
Anonymous Types - Are there any distingushing characteristics?
Can't find suitable property.
if(new {a = 2, b= "z"}.GetType()...)
what to put instead of ...?
Except for the weird name starting with <> and containing AnonymousType (in C#, as in VB it starts with VB$) there's not much to be tested. I wouldn't bet on name testing, however...
Have you tried outputting new { a = 2, b = "z" }.GetType() to get a value to compare with? If not, this is what I'd do first.
var t = new { a = 2, b = "z" }.GetType();
var c = 2; // set a breakpoint on this line, and see what t contains
Anonymous class will include the name AnonymousType, they wont have a namespace or a declaring type. You might use that to see if it's anonymous. Although I'm not sure how safe it is...
var t = new { a = 2, b = "z" }.GetType();
bool isAnonymous = t.Namespace == null && t.DeclaringType == null;