class MyBase
{
public virtual void DoSomething()
{
Console.WriteLine("MyBase DoSomething");
}
} class MyDervedClass : MyBase
{
//base 关键字来回调基的方法内容
public override void DoSomething()
{
Console.WriteLine("MyDervedClass");
base.DoSomething();
}
public void doSomething()
{
MyDervedClass MyObj2 = new MyDervedClass();
MyObj2.DoSomethingWith(this);
}
}
上面代码中有错误. public void doSomething()
{
MyDervedClass MyObj2 = new MyDervedClass();
MyObj2.DoSomethingWith(this);
}这段不对.我不明白这个this 怎么用的.后根据书中所说的写出了顶部第一段代码.且对象MyObj2没有方法DoSomethingWith();我自己手打上的.
显然错了.朋友帮心解答下.谢谢.
一眼望去
没看到带有参数的DoSomethingWith()这个方法啊
DoSomethingWith(this)方法
与
static void Main(string[] args)
{
..............实例化并使用DoSomethingWith(this)
}
谢谢.书上意思我没理解清楚.
请朋友就this关键字琮写段代码.