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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:18:12+00:00 2026-05-27T19:18:12+00:00

I dont understand : MSDN says http://msdn.microsoft.com/en-us/library/system.string.intern.aspx Consequently, an instance of a literal string

  • 0

I dont understand :

MSDN says

http://msdn.microsoft.com/en-us/library/system.string.intern.aspx

Consequently, an instance of a literal string with a particular value
only exists once in the system.

For example, if you assign the same literal string to several
variables, the runtime retrieves the same reference to the literal
string from the intern pool and assigns it to each variable.

Does this behavior is the Default (without intern ) ? or by using Intern method ?

  • If its default , so why will I want to use intern? (the instance will be once already…) ?

  • If its NOT default : if I write 1000 times this row :

    Console.WriteLine(“lalala”);

1 ) will I get 1000 occurrences of “lalala” in memory ? ( without using intern …)

2) will “lalala” will eventually Gc’ed ?

3) Does “lalala” is already interned ? and if it does , why will i need to “get” it from the pool , and not just write “lalala” again ?

Im a bit confuse.

  • 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-27T19:18:13+00:00Added an answer on May 27, 2026 at 7:18 pm

    String literals get interned automatically (so, if your code contains “lalala” 1000 times, only one instance will exist).

    Such strings will not get GC’d and any time they are referenced the reference will be the interned one.


    string.Intern is there for strings that are not literals – say from user input or read from a file or database and that you know will be repeated very often and as such are worth interning for the lifetime of the process.

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

Sidebar

Related Questions

http://msdn.microsoft.com/en-us/library/ee796239%28v=vs.91%29.aspx#Y3078 but, i am hobbyist (small time :) ) i dont understand every thing
First off, according to http://msdn.microsoft.com/en-us/library/x0b5b5bc.aspx , the List.Find method is only listed as throwing
It is said here: http://msdn.microsoft.com/en-us/library/cc903925(VS.95).aspx Silverlight does not support dynamic resources. All resource references
I am reading the build process article from MS patterns and pratices team http://msdn.microsoft.com/en-us/library/ee817676.aspx
I have been trying to work with app.config sections by this example: http://msdn.microsoft.com/en-us/library/system.configuration.configurationcollectionattribute.aspx#Y2391 and
I looked at the GetAdaptersInfo() sample in MSDN: http://msdn.microsoft.com/en-us/library/aa365917%28VS.85%29.aspx and noticed that while the
I am looking into authenticating via google. I dont understand how it works: http://code.google.com/apis/accounts/docs/OpenID.html#Samples
I came across this article about detecting VMWare or Virtual PC http://www.codeproject.com/KB/system/VmDetect.aspx and I
what is DesignMode property? When it is useful? I don't understand it from msdn
Here is code from MSDN . I don't understand why the work isn't just

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.