Please help me with the task: Want my password

Hello, I’m working on this task:

Replace getter and setter methods with corresponding properties. The property’s name should be the same as its originating methods, but without “Get” and “Set”. For example, if the method looks like this: int GetSize(), then the property should have type int and name Size. Leave all access modifiers the same.

Here is my code:


namespace Properties
{
   class WantMyPassword
   {
       private string _password;
       private string _userName;

       public string Password
       {
           get
           {
               if (_userName == "admin")
                   return _password;
               else
                   return string.Empty;
           }
           set
           {
               _password = value;
           }
       }
   }
}

Can anyone please help me to solve it?

Hi! There is a mistake in task description, I’m sorry!
Set should not be there. Your get looks perfect!
You’ll get it solved, by just removing the setter.

3 Likes

thank you. it`s work now) :heart: