错误 Class 与 StackOverflowException C# 在做什么
Bad Class with StackOverflowException What is C# doing
当我调用构造函数时,程序收到 WhosebugException。
public class User{
public User(string email, string pass){
this.email = email;
this.pass = pass;
}
public string email{
get => email;
set => email = email;
}
public string pass{
get => pass;
set => pass = pass;
}
}
进程因 WhosebugException 而终止。
这会造成无限循环
this.email = email
如何修复
public class User{
public string e;
public string p;
public User(string email, string pass){
this.e= email;
this.p= pass;
}
}
有属性
public class User{
public string e;
public string p;
public User(string email, string pass){
this.e= email;
this.p= pass;
}
public string Pass{
get { return this.p; }
set { this.p= value; }
}
public string Email{
get { return this.e; }
set { this.e= value; }
}
}
当我调用构造函数时,程序收到 WhosebugException。
public class User{
public User(string email, string pass){
this.email = email;
this.pass = pass;
}
public string email{
get => email;
set => email = email;
}
public string pass{
get => pass;
set => pass = pass;
}
}
进程因 WhosebugException 而终止。
这会造成无限循环
this.email = email
如何修复
public class User{
public string e;
public string p;
public User(string email, string pass){
this.e= email;
this.p= pass;
}
}
有属性
public class User{
public string e;
public string p;
public User(string email, string pass){
this.e= email;
this.p= pass;
}
public string Pass{
get { return this.p; }
set { this.p= value; }
}
public string Email{
get { return this.e; }
set { this.e= value; }
}
}