I need to add a custom property to the Rectangle class. I tried to subclass the Rectangle class but it didn’t work. Is there a way to do that. Thanks
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t inherit from
System.Drawing.Rectangle, because it’s not a class, it’s astruct. What you can do is to create your own class (orstruct) that wrapsRectangle, something like:Or you could hide the
Rectangleand provide methods and properties that mirror those ofRectanglethat call them.