Created
November 17, 2022 09:28
-
-
Save rofr/ec7f979dd1bf3d591397226dbaa5fb72 to your computer and use it in GitHub Desktop.
Polymorphic method invocation using dynamic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class MyBase {} | |
class A : MyBase {} | |
class B : MyBase {} | |
void Handle(Mybase m) | |
{ | |
//todo: deal with recursion that happens for types that lack a handler | |
Handle((dynamic)m); | |
} | |
void Handle(A a) {} | |
void Handle(B b) {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment