Suppose I have three methods:
void Foo(MemoryStream v) {Console.WriteLine (\"MemoryStream\");}
void Foo(Stream v) {Console.WriteLine (\"Stream\");}
void Fo
This can only be done using dynamic binding, e.g. like this:
void Bar(T value)
{
dynamic parameter = value;
Foo(parameter);
}
Note that dynamic dispatch uses the actual runtime type of the actual runtime object to do method dispatch, so there has to be an object. If value is null
, this will not work.