Upon receiving Login_Name , get will again return Login_Name , leaving you with an infinite loop ( StackOverflowException ).
You must use properties to get and set private members:
public string Login_Name { get { return _login_Name; } set { _login_Name = value; if (!string.IsNullOrEmpty(_login_Name)) { _login_Name = _login_Name.Replace("'", "''"); } } } private string _login_Name;
If you want to use the automatically implemented property, it will look like this:
public string Login_Name {get;set;}
But automatically implemented properties cannot have any additional logic applied to their sets or sets.
source share