1. I am not sure I understood why you might want to do this.
2. If you really NEED to do something like this then perhaps you need to rethink design.
3. code from Member 8070578 seems correct from logic standpoint but you will have to see if it helps you. (nevertheless +5 to that answer for giving some working code.)
4. I have a small example in which you can implement all interface functions with same name in a class and then expose a single function outside. inside this single function you will have to see which actual implementation needs to be called. (although this is working code, i would not recommend this at all. as if we are doing something like this their is some serious design flaw)
namespace C1L1
{
interface one
{
int Add(int a, int b);
}
interface Two
{
int Add(int a, int b);
}
public enum TYPE
{
SOME_TYPE,
SOME_OTHER_TYPE
}
class dummy : one, Two
{
TYPE type_;
public dummy(TYPE type)
{
type_ = type;
}
#region Two Members
int Two.Add(int a, int b)
{
Console.WriteLine("Two Add called");
return a + b;
}
#endregion
#region one Members
int one.Add(int a, int b)
{
Console.WriteLine("One Add called");
return a + b;
}
#endregion
public int Add(int a, int b)
{
Console.WriteLine("common Add called");
int result;
if (type_ == TYPE.SOME_TYPE)
{
result = ((one)this).Add(a, b);
}
else
{
result = ((Two)this).Add(a, b);
}
return result;
}
}
class Program
{
static void Main(string[] args)
{
dummy d1 = new dummy(TYPE.SOME_TYPE);
Console.WriteLine(d1.Add(2, 3).ToString());
dummy d2 = new dummy(TYPE.SOME_OTHER_TYPE);
Console.WriteLine(d2.Add(2, 3).ToString());
}
}
}