Please help me with the task: Properties or methods

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 had a name int GetSize(), then the property should have type int and name Size. Leave all access modifiers the same: private setters should stay private. Delete backing fields if possible.

Here is my code:


namespace Properties
{
   class Box
   {
       public int Width { get; set; }
       public int Height { get; set; }
   }

   class ReplaceMethodsWithProperties
   {
       
       private Box _myBox;

       public Box MyBox
       {
           get
           {
               return _myBox;
           }
           private set 
           {
               if ((box.Width > 0) && (box.Height > 0))
               {
                   _myBox = box;
               }
           }
       }


       public char MyFavoriteLetter { get; private set; }
   }
}

How can i add Box object to setter?

Taliana prompted me to substitute value

2 Likes