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 GetPassword()
       {
           if (_userName == "admin")
               return _password;
           else
               return string.Empty;
       }
   }
}

Can anyone please help me to solve it?

The task requires you to replace the method GetPassword with a property. In your case, you still have the method in place, CodeEasy is looking for a property, and can’t find it.