Why i
can call Method
? It can't see the implementation of the Method
, only declaration, isn't it? Is it upcast and boxing at the same time.. or not?
interface IB
{
void Method();
}
struct A : IB
{
public void Method() { Console.WriteLine("1"); }
}
class Program
{
static void Main()
{
A a;
a.Method();
IB i = a; // boxing.. and upcast?
i.Method(); // why it works? It looks like call of declaration
}
}
Result of work:
1
1