Pages

Tuesday, January 26, 2010

TypeCode enumeration for creating switch statements with

You can use the TypeCode enumeration to create switch statements for built-in types.

switch (Type.GetTypeCode(myObj.GetType())) {
    case TypeCode.Boolean: ...
    case TypeCode.Char: ...
    case TypeCode.String: ...
    case TypeCode.Object: ...
    default: ...
}

No comments:

Post a Comment