各位大神,请教程序Exception_WasThrown的问题

wangwei26144 2018-07-20 10:28:55
程序提出System.StackOverflowException:“Exception_WasThrown”我应该怎么改?初学C#请求帮助





using System;
using System.Collections.Generic;
using System.ComponentModel;

namespace DrawC
{
internal class JsonClass : INotifyPropertyChanged
{
public string RunNum
{
get
{
return this.RunNum;
}
set
{
this.RunNum = value;
this.NotifyPropertyChange("RunNum");
}
}
public bool UseNorepeat
{
get
{
return this.UseNorepeat;
}
set
{
this.UseNorepeat = value;
}
}
public string LuckMan
{
get
{
return this.LuckMan;
}
set
{
this.LuckMan = value;
this.NotifyPropertyChange("LuckMan");
}
}
public string SaveText
{
get
{
return this.SaveText;
}
set
{
this.SaveText = value;
this.NotifyPropertyChange("SaveText");
}
}
public List<JsonrootItem> Jsonroot
{
get
{
return this.Jsonroot;
}
set
{
this.Jsonroot = value;
}
}
public JsonClass()
{
this.Jsonroot = new List<JsonrootItem>();
this.LuckMan = "抽签抽中人员";
this.RunNum = "0个人";
this.UseNorepeat = true;
}
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChange(string propertyName)
{
if (this.PropertyChanged != null)
{
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}

}
}
...全文
12800 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
datafansbj 2019-07-05
  • 打赏
  • 举报
回复 2
你的属性值获取的 get 方法,返回的是属性值本身,这属于递归循环了,导致堆栈溢出。应该定义一个私有的变量存储属性值,get 方法返回私有的值。

111,129

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧