Welcome to MSDN Blogs Sign in | Join | Help

String equality

Flowers At the Botanical park

akutz has one of the most detailed post on string interning and equality comparison performance metrics I have ever seen. Head over to the post here

I loved his conclusion which is the crux of the whole story.

"In conclusion, the String class’s static Equals method is the most efficient way to compare two string literals and the String class’s instance Equals method is the most efficient way to compare two runtime strings. The kicker is that there must be 10^5 (100,000) string comparisons taking place before one method starts becoming more efficient than the next. Until then, use whichever method floats your boat."

Published Monday, July 21, 2008 10:46 AM by abhinaba

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: String equality

Tuesday, July 22, 2008 10:15 PM by Tim Lloyd

Thanks for providing some great posts over the years. However, I absolutely do not agree with akutz's initial conclusions as he has made at least one very basic micro-benchmarking boo-boo - using DateTime.Now (rather than a StopWatch) for providing his timings.

Please see my comments on his post.

Thanks, Tim.

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker