【发布时间】:2014-04-19 18:03:09
【问题描述】:
这段代码有什么问题?我不断收到StackOverlflowException..
public class Places
{
public string Title { get; set; }
public string Content { get; set; }
public double Latitude { get; set; }
public double Longtitude { get; set; }
public List<Places> allPlaces = new List<Places>
{
new Places { Title = "test", Content = "test\ntest", Latitude = 52.23057, Longtitude = 5.84582 },
new Places { Title = "testt", Content = "dfsdf", Longtitude = 52.35589, Latitude = 4.92119 }
};
}
【问题讨论】:
-
在实例化 allPlaces 时有一个递归。 allPlaces 在创建 allPlaces 时创建。
-
感谢您的快速回复,但我不太明白。我该如何解决这个问题?
标签: c# list class infinite-loop stack-overflow