class aaa
{private int x;
public int xx
{set
{x=value;
}
get
{return x;
}
}
}
其中value是set 隐葳的参数
这么写是正确的.
但是下面的没有编译时的错误,运行时stack overflow.
class aaa
{
public int xx
{set
{xx=value;
}
get
{return xx;
}
}
}
{private int x;
public int xx
{set
{x=value;
}
get
{return x;
}
}
}
其中value是set 隐葳的参数
这么写是正确的.
但是下面的没有编译时的错误,运行时stack overflow.
class aaa
{
public int xx
{set
{xx=value;
}
get
{return xx;
}
}
}
本文探讨了C#中属性的使用方法及其可能导致的运行时错误,特别是当属性的setter部分试图设置自身时引发的堆栈溢出问题。

被折叠的 条评论
为什么被折叠?



