I'm stunned that this doesn't even compile. This is a test program of the issue i'm having in a WCF service i'm writing (where basically the client sends the wcf service a list of different tasks, i'm then server-side processing that list of different tasks, and need to run different methods for each obviously).
Compilation error : cannot convert from 'UserQuery.IMyInterface' to 'UserQuery.MyObj1'
public interface IMyInterface{};
public class MyObj1 : IMyInterface{};
public class MyObj2 : IMyInterface{};
public String Process(MyObj1 obj)
{
return "did one";
}
public String Process(MyObj2 obj)
{
return "did two";
}
void Main()
{
IMyInterface obj = new MyObj1();
var s = Process(obj);
s.Dump();
}
MyObj1andMyObj2? Shouldn´t those handle this on their own? Your design has some strange flaws which we cannot solve probably as long as you do not say why you need these two methods where they are.