程式提出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));
}
}
}
}
uj5u.com熱心網友回復:
你的屬性值獲取的 get 方法,回傳的是屬性值本身,這屬于遞回回圈了,導致堆疊溢位。應該定義一個私有的變數存盤屬性值,get 方法回傳私有的值。轉載請註明出處,本文鏈接:https://www.uj5u.com/net/138617.html
標籤:C#
