Second on Peter Hallam's post; it's a great explanation.
You can use TypeCode to work with simple types, though.
switch (Type.GetTypeCode(myObj.GetType())) {
case TypeCode.Boolean: ...
case TypeCode.Char: ...
case TypeCode.String: ...
case TypeCode.Object: ...
default: ...
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…