Categorized | C# FAQ

Strings indepth in C#

Strings are immutable objects in C# i.e when you decale a string say string _cName=”Palle Technologies”;Now you try to manipulate the string by simply reassigning the name to : _cName=”Tech Palle”; When you try to access the  _cName you will alway get “Tech Palle” since the new string with _cName is again created . But the question here is what happens to old variable _cName ?. The answer is still old object stays in memory but now the variable _cName points to the new location where “Tech Palle” is stored and there is no way to retrieve the old string “Palle Technologies”.This is called immutability of strings.See sample “String Indepth sample in C#

EasyFreeAds Blog News Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google Yahoo Buzz StumbleUpon

6 Responses to “Strings indepth in C#”

  1. Nagaraj says:

    This give better explanation. But if some examples included that would be better

  2. Kethya says:

    Nice explanation. but give a sample too

  3. Barath says:

    Emra mama chinchesinav articles.

  4. Arvind Hindyar says:

    Please consider the below (last line) which i found in a site,is it correct..

    Q.What does the term immutable mean?
    Ans: The data value may not be changed.
    Note: The variable value may be changed, but the original immutable data value was discarded and a new data value was created in memory.

  5. Naresh says:

    Good Explanation and this will improve knowledge indepthly in C#

Trackbacks/Pingbacks


Leave a Reply