首页 > 代码库 > C# 总是在set处抛出 system stack over flow exception的异常是什么原因
C# 总是在set处抛出 system stack over flow exception的异常是什么原因
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
People tom = new People() ;
tom.Name =" Tom";
tom.Age = 18;
tom.MyPlace = Console.ReadLine();
Console.WriteLine(tom.MyPlace);
Console.ReadKey();
}
}
public class People
{
public string Name;
public int Age;
public string MyPlace
{
get
{
return MyPlace;
}
set
{
if (value =http://www.mamicode.com/="北京")
{
MyPlace = value;
}
else
{
MyPlace = "不符合要求";
}
}
}
}
}
C# 总是在set处抛出 system stack over flow exception的异常是什么原因