A
Alex Sedow
Example 1
interface I
{
string ToString();
}
public class C : I
{
public void f()
{
ToString(); // IL: callvirt instance string object::ToString()
}
}
Interface I (like any other interface) implicitly derived from
System.Object.
Why interface ToString() method doesn't hide System.Object.ToString()
method?
//--------------------------------------------------------------------------
----
Example 2
interface I
{
void f();
}
public class B
{
public virtual void f()
{}
}
class D : B, I
{
void g()
{
f(); // call B.f();
}
}
Class D inherit to methods with the same signatures: first - from class B,
and second - from interface I.
Why f() call is not ambiguous?
//--------------------------------------------------------------------------
----
And last question. Is members declared in base class has more priority than
members declared in base interfaces?
Alex.
interface I
{
string ToString();
}
public class C : I
{
public void f()
{
ToString(); // IL: callvirt instance string object::ToString()
}
}
Interface I (like any other interface) implicitly derived from
System.Object.
Why interface ToString() method doesn't hide System.Object.ToString()
method?
//--------------------------------------------------------------------------
----
Example 2
interface I
{
void f();
}
public class B
{
public virtual void f()
{}
}
class D : B, I
{
void g()
{
f(); // call B.f();
}
}
Class D inherit to methods with the same signatures: first - from class B,
and second - from interface I.
Why f() call is not ambiguous?
//--------------------------------------------------------------------------
----
And last question. Is members declared in base class has more priority than
members declared in base interfaces?
Alex.