Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8621887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:55:13+00:00 2026-06-12T06:55:13+00:00

I have a method of type Rectangle and it needs to return: True: The

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T06:55:15+00:00Added an answer on June 12, 2026 at 6:55 am
    public Rectangle (Rectangle rect) {};
    

    That ‘method’ is a constructor.

    Override the Object ToString() and implement it the way you want. Call it from another class.

    public override string ToString()
    {
        return "Rectangle";
    }
    

    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…)

    public void ManipulateRectangle(Rectangle rect) 
    {
        rect.GetWidth(); //I don't know your rectangle class methods or data members.
        rect.GetHeight(); //etc.
    }
    

    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.

    public Rectangle ManipulateRectangle(Rectangle rect) 
    {
        var newRectangle = new Rectangle();
        newRectangle.SetWidth(rect.GetHeight()); //ex manipulation
    
        return newRectangle;
    }
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this method call: public DataTemplate Create(Type type, string propertyName) { string str
I have a method that receives something and it needs to determine the type
I have a method that returns a list of type string. I want to
I have a method that I specify to be of a certain type. E.g.
I have a MethodInfo of an interface method and Type of a class that
I have a method Foo4 that accepts a parameter of the type Func<>. If
I have the following method public static void SerializeToXMLFile(Object obj,Type type, string fileName) {
I have an interface that has a generic method with two type parameters. I
Say I have two classes: @interface Rectangle: NSObject { int width; int height; }
I have a Method that get paramater of type - Exception WriteException(Exception ex, int

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.