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 4323814
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:03:02+00:00 2026-05-21T09:03:02+00:00

I have searched both Google and this site to find an answer. I have

  • 0

I have searched both Google and this site to find an answer. I have also read it in my class book, but I still don’t understand how it is applied.

Here is what I know:

  • It is used to display what an object knows about itself.

  • It can be used to format the output about what it knows about itself.

  • It has be be overridden in the method to be used.

  • 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-05-21T09:03:03+00:00Added an answer on May 21, 2026 at 9:03 am

    Thinking that you have a class like:

    public class Person
    {
       public string FirstName { get; set;}
       public string LastName { get; set;}
       private string age;
    }
    

    Using this:

    public override string ToString()
    {
       return string.Format("[First Name: {0}; Last Name: {1}; Age: {2}]", FirstName, LastName, age);
    }
    

    will reveal all the internals of the class. Actually it is best used for quickly retrieving public fields of the class in a pre-formatted manner (thus effectively converting the data encapsulated in the class into a string).

    Also here is a very useful advice from the book Pro C# 2010 and the .NET 4 Platform: “Many classes (and structures) that you create can benefit from overriding ToString() in order to return a string textual representation of the type’s current state. This can be quite helpful for purposes of debugging (among other reasons). How you choose to construct this string is a matter of personal choice; however, a recommended approach is to separate each name/value pair with semicolons and wrap the entire string within square brackets. However, always remember that a proper ToString() override should also account for any data defined up the chain of inheritance. When you override ToString() for a class extending a custom base class, the first order of business is to obtain the ToString() value from your parent using the base keyword. Once you have obtained your parent’s string data, you can append the derived class’s custom information.”

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

Sidebar

Related Questions

I have searched google, but I didn't find anything. I searched this site and
I have searched Google and Stackoverflow for this question, but I still don't understand
I have searched for a general solution to this but only find answers to
I have searched Google and Stack Overflow for a answer to my query, but
I have searched all morning and yesterday afternoon and still cannot find an solution
I have searched and searched for this but I think my terminology isn't correct
I have searched apple's documentation and other posts on Stack Overflow, but I'm still
Struggling with this problem for an hour now and searched both stackoverflow and google
I have searched here and on Google, but as an inexperienced Javascript hack I'm
I've searched quite a bit on both google and stackoverflow, but a lack of

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.