运行后,提示该程序会一直循环。不知道问题在哪里了??求解啊
using System;using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _18new_用法
{
public class A //基类
{
public void Work()
{
Console.WriteLine("这是基类,这是sssbbb");
}
public int worka;
public int workb
{
get
{
return 0;
}
}
}
public class B : A
{
public new void Work()
{
Console.WriteLine("这里是派生类,这是白痴");
}
public new int workb
get
{
return 0;
}
set
{
workb = value; //此处就是提醒错误的地方,说循环问题
}
}
}
class Program
{
static void Main(string[] args)
{
B b = new B(); //
b.Work(); //
A a = (A)b;
a.Work();
Console.WriteLine(b .workb); //
b. workb=9;
b.worka = 9; //
Console.WriteLine("a="+"{0}",b.worka);
Console.WriteLine("b="+"{0}",b.workb);
Console.ReadKey();
}
}
}
到底错在哪里啊?