本文介绍了计算器在类的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
的
我有了一个名为isAuthenticated属性与下面的代码一个简单的类调用MyClass的:
I have a simple class call myClass that has a property called isAuthenticated with the following code:
public class myClass
{
public myClass()
{
this.isAuthenticated = false;
}
public bool isAuthenticated
{
get { return isAuthenticated; }
set { isAuthenticated = value; }
}
}
当我initalize I类上获得一个计算器集合{...}行,我究竟做错了什么?
When I initalize the class I get a stackoverflow on the set {...} line, what am I doing wrong?
推荐答案
在的getter / setter的自称。添加一个成员变量
The getter/setter is calling itself. Add a member variable.
{
bool isAuthenticated;
public myClass()
{
IsAuthenticated = false;
}
public bool IsAuthenticated
{
get { return isAuthenticated; }
set { isAuthenticated = value; }
}
}
这篇关于计算器在类的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!