interface IA
{
int DoA();
}
interface IB
{
int DoB();
}
These are two interfaces. My method needs to implement the parameters of both interfaces. Is there any way to restrict the caller?
I've thought about a lot of things That I can think of.
For example,
1: use the generic
int MyMethod<T>(T x)where T:IA,IB
It feels ok,but what is the point of generics for this method if the caller will always just treat the class as a parameter and never use the structure?
2:
int MyMethod(IA x)
{
The IB temx = x (IB);
...
}
I don't think this is the best.
//============================
so is there a way for the compiler to restrict the caller?
(By the way, why are delegates designed as classes and not structs?)