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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:50:33+00:00 2026-06-15T00:50:33+00:00

Possible Duplicate: Does C# optimize the concatenation of string literals? I just found out

  • 0

Possible Duplicate:
Does C# optimize the concatenation of string literals?

I just found out that we write a line like this:

string s = "string";
s = s + s; // this translates to s = string.concat("string", "string");

However I opened the string class through reflector and I don’t see where this + operator is overloaded? I can see that == and != are overloaded.

[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
    public static bool operator ==(string a, string b)
    {
      return string.Equals(a, b);
    }
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
    public static bool operator !=(string a, string b)
    {
      return !string.Equals(a, b);
    }

So why does concat gets called when we use + for combining strings?

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. Editorial Team
    Editorial Team
    2026-06-15T00:50:35+00:00Added an answer on June 15, 2026 at 12:50 am

    So why does concat gets called when we use + for combining strings?

    Section 7.7.4 of the C# specification, “Addition operator”, defines a binary addition operator for strings, where the operator returns the concatenation of the operands.

    The definition of System.String in the CLI specification includes several Concat overloads, but no + operator. (I don’t have a definitive answer explaining that omission, but I suppose it’s because some languages define operators other than + for string concatenation.)

    Given these two facts, the most logical solution for the C# compiler writer is to emit a call to String.Concat when compiling the +(string, string) operator.

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

Sidebar

Related Questions

Possible Duplicate: Does PHP have threading? I found this: http://php.net/manual/en/function.pcntl-fork.php But I can't tell
Possible Duplicate: Does fast enumeration in Objective-C guarantee the order of iteration? Just a
Possible Duplicate: How does this CSS triangle shape work? Please help me i need
Possible Duplicate: Does anyone beside me just NOT get ASP.NET MVC? I dont know
Possible Duplicate: Why does C# not provide the C++ style ‘friend’ keyword? I'd like
Possible Duplicate: How does one escape characters in Delphi string In Delphi a string
Possible Duplicate: Does a finally block always run? I learned that the finally clause
Possible Duplicate: Does readdir() guarantee an order? I'm guessing this isn't the case, and
Possible Duplicate: Does every thread need its own autorelease pool? I would like to
Possible Duplicate: Does Java guarantee that Object.getClass() == Object.getClass()? If I have a class

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.