Possible Duplicate:
Using Case/Switch and GetType to determine the object
If I hope to rewrite my codes with syntax if (...) else if (...) into the syntax with switch (...) case for following codes, how to achieve it ?
void Foo(object aObj) {
if (aObj is Dictionary<int,object> ) {
} else if (aObj is string) {
} else if (aObj is int) {
} else if (aObj is MyCustomClass) {
} else {
throw new Exception("unsupported class type.");
}
}