当我尝试覆盖get和set函数时,我不确定导致StackOverflowException的原因.当我只使用默认的get并设置它有效.
enum MyEnumType
{
....
}
public MyEnumType data { get; set; }
Run Code Online (Sandbox Code Playgroud)
但是当我尝试添加其他数据时,它会抛出StackOverflowException
public MyEnumType data
{
get
{
return data;
}
set
{
data = value;
}
}
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?当我为asp .net用户控件属性执行此操作时,没有问题.我想知道为什么它导致正常枚举数据类型的StackOverflowException.
我的代码中出现此错误
MedCareProviderLibrary.dll中发生未处理的"System.StackOverflowException"类型异常
这是我的代码片段以及错误的来源.它在带有错误的零件上给出了一个黄色箭头.
显示错误的部分以粗体显示.任何帮助将不胜感激谢谢
private string _TestNo;
private string _TestType;
private DateTime _TestDate;
private string _PatientNo;
private string _DoctorNo;
public Test()
{
_TestNo = "";
_TestType = "";
_TestDate = new DateTime();
_PatientNo = "";
_DoctorNo = "";
}
public Test(string aTestNo, string aTestType, DateTime aTestDate, string aPatientNo, string aDoctorNo)
{
_TestNo = aTestNo;
_TestType = aTestType;
_PatientNo = aPatientNo;
_DoctorNo = aDoctorNo;
}
public string TestNo
{
set { _TestNo = value; }
get { return (TestNo); }
} …Run Code Online (Sandbox Code Playgroud) 这是我的代码的属性:
public KPage Padre
{
get
{
if (k_oPagina.father != null)
{
this.Padre = new KPage((int)k_oPagina.father);
}
else
{
this.Padre = null;
}
return this.Padre;
}
set { }
}
Run Code Online (Sandbox Code Playgroud)
但它说:
App_Code.rhj3qeaw.dll中发生未处理的"System.StackOverflowException"类型异常
为什么?我该如何解决?
更正代码后,这是我的实际代码:
private KPage PadreInterno;
public KPage Padre
{
get
{
if (PadreInterno == null)
{
if (paginaDB.father != null)
{
PadreInterno = new KPage((int)paginaDB.father);
}
else
{
PadreInterno= null;
}
}
return PadreInterno;
}
}
Run Code Online (Sandbox Code Playgroud)
你有什么想法?