F
Fuzzy
If an object implements an interface, are interface methods always
virtual or only if accessed through the interface?
For example, if I have:
interface IFoo
{ public void Method1() }
and I have:
class Bar : IFoo
{
public void Method1(){} // IFoo method
public void Method2(){}
}
test code..
IFoo itfRef;
IBar objRef = new Bar();
itfRef = (IFoo)objRef;
itfRef.Method1(); // is a virtual call
objRef.Method1(); // ??
objRef.Method2(); // not a virtual call
Is objRef.Method1() also a virtual call or is this a direct call?
virtual or only if accessed through the interface?
For example, if I have:
interface IFoo
{ public void Method1() }
and I have:
class Bar : IFoo
{
public void Method1(){} // IFoo method
public void Method2(){}
}
test code..
IFoo itfRef;
IBar objRef = new Bar();
itfRef = (IFoo)objRef;
itfRef.Method1(); // is a virtual call
objRef.Method1(); // ??
objRef.Method2(); // not a virtual call
Is objRef.Method1() also a virtual call or is this a direct call?