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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:31:54+00:00 2026-05-16T06:31:54+00:00

i am reading Accelerated C# 2010. and have a few questions Question 1 Instances

  • 0

i am reading Accelerated C# 2010. and have a few questions

Question 1

Instances of String are immutable in
the sense that once you create them,
you cannot change them

how is that true. i have not used C# for sometime, plus i am just starting so i maybe wrong even in the syntax.

string str1 = "this is a string"; // i hope my syntax is right 
str1 = "this is a NEW string"; // i think i can do this right? 

Question 2

If you call the ICloneable.Clone
method on a string, you get an
instance that points to the same
string data as the source. In fact,
ICloneable.Clone simply returns a
reference to this

if this is true, it means that

string str1 = "string 1";
// i hope my syntax is right too. i am really not sure about this
string str2 = str1.Clone(); 
str2 = "modified string"; // will str1 be modified too? 
  • 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-16T06:31:55+00:00Added an answer on May 16, 2026 at 6:31 am
    string str1 = "this is a string"; // i hope my syntax is right 
    str1 = "this is a NEW string"; // i think i can do this right? 
    

    Sure! string is a reference type (a pointer, if you want so see it like this), so in line 2, you are making variable str1 point to a different (constant) string in memory. The original string is not changed, it’s just not referenced any more.

    string str1 = "string 1";
    string str2 = str1.Clone(); // i hope my syntax is right too. i am really not sure about this
    str2 = "modified string"; // will str1 be modified too? 
    

    No, because you didn’t modify "string 1". After line 2, it looked like this:

    memory            "string 1"
                        ^    ^ 
                        |    |
    stack             str1  str2
    

    After line 3, it looks like this:

    memory            "string 1"     "modified string"
                          ^              ^
                          |              |
    stack                str1           str2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Reading through the CKEditor documentation , I see that they have an option to
I've been reading Accelerated C++ and I have to say it's an interesting book.
I'm working on an a GPU accelerated program that requires the reading of an
Reading questions, comments and answers on SO, I hear all the time that MSVC
Reading the book VS 2010 by John Sharp, it says that generics allows to
Reading across difference lineage of CPU created by intel , many questions aroused in
Reading some questions here on SO about conversion operators and constructors got me thinking
I came across this code today whilst reading Accelerated GWT (Gupta) - page 151
Reading or writing a C code, I often have difficulties translating the numbers from
Reading the code of many javascript libraries, I see that many developers use to

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.