My First Version :
bool IsDynamicType(object obj){
return obj is dynamic;
}
it's fault because all class object will return true,ex:
var b1 = new {} is dynamic; //True
var b2 = new object() is dynamic; //True
I know new {}
system will compiler <>f__AnonymousType01
.
My current way to check object is dynamic :
bool IsDynamicType(object obj){
return Regex.IsMatch(obj.GetType().Name,@"AnonymousType");
}
I am having a problem now if class's name is xxxAnonymousTypexxx
this function will return true.