public class Class1
{
public Class1()
{
prop = new Class2();
}
public Class2 prop { get; set; }
public class Class2
{
public Class2()
{
this.prop2 = "nikola";
}
public string prop2 { get { return prop2; } set { prop2 = EditString(value); } }
public string EditString(string str)
{
str += " plavsic";
return str;
}
}
}
这是我有问题的代码。当我尝试初始化 Class1 类型的对象时,它会引发 StackOverflowException 错误。我究竟做错了什么?