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

  • Home
  • SEARCH
  • 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 6905097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:08:32+00:00 2026-05-27T08:08:32+00:00

I am just a bit confused with strings, and their comparison. What I understand

  • 0

I am just a bit confused with strings, and their comparison.
What I understand is that doing this :

string one = "stackoverflow";
string two = "stackoverflow";

bool equal = one == two;

This will compare character by character right?

Why is this the case? if string are immutable, and two variables will always refer to the same string if they have equal characters. Why doesn’t the compiler just checks the references?
If there is one place where I would think that references equality means value equality I would think that would be for strings. What am I missing?

  • 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-27T08:08:33+00:00Added an answer on May 27, 2026 at 8:08 am

    It is true that string literals are automatically interned, but not all strings are interned. When you build a string dynamically or get it somehow during runtime, it will not be interned by default – you need to call String.Intern for that to happen.

    This means you can have identical string instances with different references.

    So, in your case, if you dynamically build the string “stackoverflow” twice and assign each to the variables one and two, the references of one and two will be different, though the value is identical.

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

Sidebar

Related Questions

I'm beeing bit confused here. SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.bugs_list_item, itemCursor, new String[]
I am bit confused about ADO.Net Data Services. Is it just meant for creating
Sorry. I'm just bitten (or bit. Go figure with this left-to-right language :-) I've
So, I was just coding a bit today, and I realized that I don't
Just need a little bit of Javascript to warn people that press the back
This may seem silly, but I'm a bit confused about the following code: public
I'm a little bit confused about something. I was under the impression that the
I'm a bit confused here. I'm copying all the controls from one form to
I am a bit confused right now. I have a J2ME app that sends
I'm new to Ruby and a bit confused by the grep command in this

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.