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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:23:46+00:00 2026-05-27T20:23:46+00:00

I am following the Preamble: what is a reference type? where it explains parameters

  • 0

I am following the Preamble: what is a reference type? where it explains parameters passing as value or reference type. The first example has the following code:

using System;
using System.Text;

public class Example1
{
    public static void Main (string[] args)
    {
        StringBuilder first = new StringBuilder();
        StringBuilder second = first;
        first.Append ("hello");
        first = null;
        Console.WriteLine (second);
    }
}

And it does not provide the source code for the class (or struct) of StringBuilder, and I do not know how the Console.WriteLine(second) is able to return a string value just by using the identifier. Is it possible to return a value in the constructor?

I tried to write the class or struct by following (and it doesn’t work):

struct StringBuilder
{
    private string _myString;
    public string StringBuilder
    {
        get { return _myString; }
        set { _myString = value; }
    }
    public void Append(string str)
    {
        _myString = str;
    }
}
  • 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-27T20:23:46+00:00Added an answer on May 27, 2026 at 8:23 pm

    Have a look a the documentation for Console.WriteLine(object value). It says this:

    the ToString method of value is called to produce its string
    representation, and the resulting string is written to the standard
    output stream.

    So (as others have written), if you want to print a string representation of your own class or struct, you should override the ToString() method.

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

Sidebar

Related Questions

Following code is an example of text placed into a textarea from a database.
Following example code from the libpcap documentation yields the following code which should report
Following is some obviously-defective code for which I think the compiler should emit a
I have the following query that I'm executing using a Python script (by using
following code is used to find url from a string with php. Here is
following piece of code: class a{ public function __get($key) { if($key == 'obj') {
The following snipit of code works fine, except for the fact that the resulting
Following http://maksim.sorokin.dk/it/2010/06/10/izpack-with-maven/ I wrote a Maven POM which creates an IzPack installer, using the
Following code: <?php $test_array = array(); $test_array['string_index'] = data in string index; $test_array[] =
Following s my Code to display data to listview from database. But it will

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.