关于用多态访问接口方法的疑惑
static void Main(string[] args)
{
DerivedClass sww= new DerivedClass();
BaseClass sd = sww;
// Console.Write(sd.ToString());
sd.DoWork();
// sww.DoWork();
// Iwangge shenme = sww;
// shenme.DoWork();
}
}
public class BaseClass :Iwangge
{
public void DoWork() { }
public virtual int WorkProperty
{
get { return 0; }
}
}
public class DerivedClass : BaseClass,Iwangge
{
public void DoWork() { }
public static void sdsss()
{ }
public override int WorkProperty
{
get { return 0; }
}}
public interface Iwangge
{
void DoWork();
}
}
//sd.DoWork();访问的为什么是基类中的dowork方法,他不是派生类的引用吗?