I have a method of type Rectangle and it needs to return:
True:
- The name of rectangle passed to the method
Else:
- Width and height of that rectangle
This is the method: public Rectangle ReturnStuff(Rectangle rect) {...stuff...};
I’ve tried loads of stuff – for example (Rectangle) rect.ToString(); ConvertToString/Int()…
but nothing seems to work.
Any tips?
Thanks
That ‘method’ is a constructor.
Override the Object
ToString()and implement it the way you want. Call it from another class.Might want to return things like width height etc.
EDIT:
As you’ve changed your questionf from a Copy Constructor to a method of return type Rectangle I should probably clarify.
If you want the rectangle being passed in do this: (don’t know why you had a semicolon on the end of the method…)
Now if that’s not what your looking for and instead you want to get a rectangle (by passing in a rectangle? I’m not sure why – unless your manipulating it in some way) you have to actually return an object of type Rectangle.
Just for refrence try to make your questions a little more specific 🙂 It helps. Also names of methods, code that belongs in them, and what exactly you want to do should be included.