You need
explicit interface implementation. Here is the syntax:
interface IFirstTest {int Add(); }
interface ISecondTest {int Add(); }
class DoubleTest : IFirstTest, ISecondTest {
int IFirstTest.Add() { return ++value; }
int ISecondTest.Add() { value += 2; return value; }
int value;
}
Even though your problem hardly can have practical sense, it illustrates the syntax which has benefits over
implicit implementations and can solve
real problems.
One of such problems is: how two write two indexed properties with the same number of indices of different types in one class? This will not compile:
class MyClass {
public int this[int index] { }
public double this[string index] { }
}
The solution is:
class MyClass {
public int this[int index] { }
double MyInterface.this[string index] { }
}
interface MyInterface {
double this[string index] { }
}
In general case, I would rather advise explicit implementation (even if there are no problems illustrated above); it helps to promote using classes purely through interfaces.
[EDIT]
To answer the original question, you should have tried to work with your class through both interfaces:
Itest2 first = new test();
Itest1 second = new test();
first.Add();
second.Add();
You would see that in both cases, the same function is called; so, in this sense, you have implemented both interfaces at once. The case of implementing of two identical unrelated interfaces is pathological; I don't have it ever makes any practical sense, but you can see it's not prohibited by the compiler.
—SA