What I want to do is something like this:
switch( myObject.GetType().GetProperty( \"id\") )
{
case ??:
// when Nullable, do this
I've been using the following type of code to check if the type is nullable and to get the actual type:
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>))
{
return Nullable.GetUnderlyingType(type);
}
If the type is e.g. Nullable this code returns the int part (underlying type). If you just need to convert object into specific type you could use System.Convert.ChangeType method.