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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:06:08+00:00 2026-05-11T07:06:08+00:00

This is taken from Jon Skeet’s excellent personal C# site ( http://www.yoda.arachsys.com/csharp/ ): StringBuilder

  • 0

This is taken from Jon Skeet’s excellent personal C# site (http://www.yoda.arachsys.com/csharp/):

StringBuilder first = new StringBuilder(); StringBuilder second = first; first.Append ('hello'); first = null; Console.WriteLine (second); 

1) Changing the value of first will not change the value of second –

2) although while their values are still references to the same object, any changes made to the object through the first variable will be visible through the second variable.

This is taken from the same sentence. What is meant by changing the value? I assume the value of a variable (eg int x = 4, or 5, or 45, etc).

Does this mean if first points to another compatible object, it won’t have an effect on two?

Everything on that page makes sense, I think it’s just an issue with my interpretation of the English.

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. 2026-05-11T07:06:09+00:00Added an answer on May 11, 2026 at 7:06 am

    first is a reference to an object of type StringBuilder. That is, first stores a value that can be used to refer to an object on the heap that is type of Stringuilder. second is another reference to an object of type StringBuilder and its value is initially set refer to the same object that first is referring to.

    If you change the value of first what you are doing is changing what the referent is. That is, you are using first to refer to a different object. This does not impact second; its value is unaffected by changes to the value of first. (Remember: the value of first and second are references that initially have the same referent. But just like with

    int x = 1; int y = x; x = 2; 

    does not change the value of y, changing the value of first does not change the value of second.

    On the other hand, when first and second refer to the same object, any changes to that object will be visible through both first and second.

    Think of it like this. Let’s say I create a text file first.html whose contents are

    <a href='http://stackoverflow.com'>Stack Overflow</a> 

    and I issue the command copy first.html second.html. Then both pages can be used to refer to the same webpage; by following the link we arrive at the same referent. If changes are made to the Stack Overflow home page, then accessing the homepage through either first.html or second.html will allow me to see those changes. But if I then change the contents of first.html to be

    <a href='http://www.thedailywtf.com>The Daily WTF</a> 

    then I can no longer use first.html to refer to the Stack Overflow homepage. Moreover, this change does not impact the value of second.html. It is still

    <a href='http://stackoverflow.com>Stack Overflow</a> 

    Think of the contents of these files as the values of a reference type, and the ultimate desination as the referent object.

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

Sidebar

Ask A Question

Stats

  • Questions 104k
  • Answers 104k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer As most countries have several official languages you should rely… May 11, 2026 at 8:38 pm
  • Editorial Team
    Editorial Team added an answer You can use: Point clientPoint = TreeView.PointToClient( new Point( e.X,… May 11, 2026 at 8:38 pm
  • Editorial Team
    Editorial Team added an answer Put this at the start of the script SCRIPTNAME=`basename $0`… May 11, 2026 at 8:38 pm

Related Questions

This is taken from Jon Skeet's excellent personal C# site ( http://www.yoda.arachsys.com/csharp/ ): StringBuilder
I've heard it said that it is difficult to design for inheritance, but I've
As an exercise, I'm translating parts of our large and battle-hardened Delphi-framework to C#.
I wrote a quick and dirty wrapper around svn.exe to retrieve some content and
Is there a way to enforce/limit the types that are passed to primitives? (bool,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.