how to improve this method using polymorphism+overloading so as to reduce IS (type check)?
问题 For example BaseClass MyBase() { public int Add(BaseClass next) { if (this is InheritedA && next is InheritedA) return 1; else if (this is InheritedA && next is InheritedB) return 2; else if (this is InheritedB && next is InheritedA) return 3; else if (this is InheritedB && next is InheritedB) return 4; } } where InheritedA , and InheritedB are its inherited classes. In fact, there are more Inherited classes, and the Add returns different results based on the order and types of its operand. I