“String interning and String.Empty” by Eric Lippert

This one is sure to trip you up at some point if you’re not aware of it.  In a nutshell, .NET runtime will “intern” two (or more) value-identical strings inside a single compilation unit that have the same value, so that there is only one actual copy of the literal and the two (or more) string reference variables both point to it.  This can lead to some unexpected equality testing (==) resutls!  More details and great examples can be found in the full blog posting:

String interning and String.Empty” by Eric Lippert

Thanks to elijahmanor for the tweet.


0 Responses to ““String interning and String.Empty” by Eric Lippert”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Scott’s recent tweets…


%d bloggers like this: