How can I make this work?
switch(property.PropertyType){ case typeof(Boolean): //doStuff break; case typeof(String): //doOtherStuff break; default: break; }
I don’t want to use the name since string comparing for types is just awfull and can be subject to change.
You can use an hybrid approach for TypeCode.Object where you dynamic if with typeof. This is very fast because for the first part – the switch – the compiler can decide based on a lookup table.