C# calling overridden subclass methods without knowledge that it's a subclass instance
问题 I have a base class with a virtual method, and multiple subclasses that override that method. When I encounter one of those subclasses, I would like to call the overridden method, but without knowledge of the subclass. I can think of ugly ways to do this (check a value and cast it), but it seems like there should be an in-language way to do it. I want the List to contain multiple subclasses within the same list, otherwise obviously I could just make a List. EDIT: Fixed the comment in the code