Reputation: 219
I want to override getter and setter method in my user.cs model but its not working and I am getting an error when I try to login, when I try to not override, it is working fine.
public string UserPassword
{
get { return this.UserPassword; }
set { this.UserPassword = value; }
}
When I try to login, I get this error:
An unhandled exception of type 'System.StackOverflowException' occurred in PMS.dll
Please check the screenshot.
Upvotes: 0
Views: 859
Reputation: 17943
StackoverFlow exception : This usually means that you have a recursive call in your code. A recursion is simply a method that calls itself, causing the stack to overflow and throw the StackoverFlow exception
In your case UserPassword
property calls to itself recursively causing the stack overflow.
You need to change your property like following.
public string UserPassword
{
get;
set;
}
Or like
string _userPassword;
public string UserPassword
{
get { return _userPassword; }
set { _userPassword = value; }
}
Upvotes: 3