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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:05:50+00:00 2026-06-11T00:05:50+00:00

I am VERY new to C# programming with a light backround in C++ and

  • 0

I am VERY new to C# programming with a light backround in C++ and HTML, so I am pretty much starting from scratch. I was looking though the msdn tutorials, the properties tutorial specfically, and there is only one part so far I do not understand. There is a part in the code goes like this:

// person.cs

using System;

class Person
{

private string myName ="N/A";

private int myAge = 0;

// Declare a Name property of type string:
public string Name
{
    get 
    {
       return myName; 
    }
    set 
    {
       myName = value; 
    }
}

// Declare an Age property of type int:
public int Age
{
    get 
    { 
       return myAge; 
    }
    set 
    { 
       myAge = value; 
    }
}

public override string ToString()
{
    return "Name = " + Name + ", Age = " + Age;
}

public static void Main()
{
    Console.WriteLine("Simple Properties");

    // Create a new Person object:
    Person person = new Person();

    // Print out the name and the age associated with the person:
    Console.WriteLine("Person details - {0}", person);

    // Set some values on the person object:
    person.Name = "Joe";
    person.Age = 99;
    Console.WriteLine("Person details - {0}", person);

    // Increment the Age property:
    person.Age += 1;
    Console.WriteLine("Person details - {0}", person);
}
}

and the program’s output is this:

Simple Properties
Person details - Name = N/A, Age = 0
Person details - Name = Joe, Age = 99
Person details - Name = Joe, Age = 100

Now I understand that {0} is effectivly a placeholder that references a part of the code, in this case it is “person”, but I do not understand how this part:

public override string ToString()
{
    return "Name = " + Name + ", Age = " + Age;
}

is listed under “person”. I don’t see the connection like I do with “name” and “age”. Could someone highlight the part of the code that makes the connection and possibly explain it as well if it is not to much to ask? Thank you very much in advance.

  • 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-11T00:05:51+00:00Added an answer on June 11, 2026 at 12:05 am

    You are using string formatting. The WriteLine has an overload where the first parameter is a format string, so you are doing the same thing as:

    Console.WriteLine(String.Format("Person details - {0}", person));
    

    The Format method takes the value parameters and turns them into strings, then inserts them into the format string. The standard method for turning anything into a string is calling the ToString method, which every objects has. If you want to specify what something looks like when it is turned into a string, you override the ToString method.

    So, in the end the code is doing the same as:

    Console.WriteLine("Person details - " + person.ToString());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm pretty new to programming and my only experience is some very light C#
I'm very much new to programming and have been doing fairly well so far.
I'm very new to programming and I'm just starting to learn VBA with excel.
I am very new to programming and I can't seem to find a way
I'm still very new at programming, and our local SSIS genius isn't here today
I'm very new to programming and I am trying to write a program that
I am very new to programming with jQuery and I am trying to retrieve
I am very new to programming in general, while reading about PHP I saw
I am very new to python programming and have yet to buy a textbook
I am very new to C++ programming and you will see why. I want

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.