Skip to content

Instantly share code, notes, and snippets.

@rofr
Created November 17, 2022 09:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rofr/ec7f979dd1bf3d591397226dbaa5fb72 to your computer and use it in GitHub Desktop.
Save rofr/ec7f979dd1bf3d591397226dbaa5fb72 to your computer and use it in GitHub Desktop.
Polymorphic method invocation using dynamic
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