死循环。。 赋值的调用了set set里又对自身进行赋值。。。无限递归。。 当然会出现这个错误
應該是這樣的呢,這個是別人回答的!
http://topic.csdn.net/u/20120414/17/4973fc2b-de0b-4665-b190-b91061bc6d12.html
把代码修改如下,增加int width;//定义字段
即:
class Person { int width;//定义字段
public int Width { set { this.width = value; } get { return width; } } } Person p = new Person(); p.Width = 30;
属性是字段的封装,是对字段的读、写。