A must read about string comparison options and also very important performance notes !

dotNetDave's avatardotNetTips.com

code-performance-book-cover-2-5x-1In Microsoft .NET there are many ways to compare strings. I would say that most of the code I analyze, I see it done one of these two ways:

bool result = email1 == email2;
bool result = email1.Equals(email2);

Is this the best way to compare strings? The quick answer is no. While this works, it doesn’t take into consideration localization and globalization. I’ve seen many developers convert the strings to lower or uppercase characters which does affect performanceĀ  and might not have the results they expect. So, let us see how to properly compare strings while thinking about globalization and performance.

Here is how Wikipedia defines localization and globalization:

In computing, internationalization and are means of adapting computer software to different languages, regional peculiarities and technical requirements of a target locale. Internationalization is the process of designing a software application so that it can be adapted to various…

View original post 511 more words

Leave a comment

Discover more from El Bruno

Subscribe now to keep reading and get access to the full archive.

Continue reading