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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:10:36+00:00 2026-05-11T08:10:36+00:00

The MSDN article on String Basics shows this: string str = hello; string nullStr

  • 0

The MSDN article on String Basics shows this:

string str = 'hello'; string nullStr = null; string emptyStr = '';  string tempStr = str + nullStr; // tempStr = 'hello' bool b = (emptyStr == nullStr);// b = false; string newStr = emptyStr + nullStr; // creates a new empty string int len = nullStr.Length; // throws NullReferenceException 

Why doesn’t concatenating with null throw a null reference exception? Is it to make a programmer’s life easier, such that they don’t have to check for null before concatenation?

  • 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. 2026-05-11T08:10:36+00:00Added an answer on May 11, 2026 at 8:10 am

    From MSDN:

    In string concatenation operations, the C# compiler treats a null string the same as an empty string, but it does not convert the value of the original null string.

    More information on the + binary operator:

    The binary + operator performs string concatenation when one or both operands are of type string.

    If an operand of string concatenation is null, an empty string is substituted. Otherwise, any non-string argument is converted to its string representation by invoking the virtual ToString method inherited from type object.

    If ToString returns null, an empty string is substituted.

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

Sidebar

Related Questions

As per this MSDN article: W3C Extended Log File Format (IIS 6.0) It says
I've followed the instructions in this MSDN article: http://msdn.microsoft.com/en-us/library/dd206945.aspx Is it possible to call
Is the advice given in this oft-cited MSDN article still considered sound for converting
This article on MSDN states that you can use as many try catch blocks
The MSDN article on String.Normalize states simply: Returns a new string whose binary representation
Near the bottom of this article ( MSDN ) in a section entitled The
The MSDN gives this code example in the article on the Func Generic Delegate
From this MSDN article , there's quite a few ways to hook up a
I have been playing with the demo code from this msdn article by Jeffrey
In this article: http://msdn.microsoft.com/en-us/library/ms171728(VS.80).aspx The author uses the following method to make thread-safe calls

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.