|
How to compare two Strings in C#Best way how to compare two string is using methode String.Compare(String, String, Boolean). For third parameter (Boolean) you can use true if you want to ignore case during the comparison; otherwise use false or leave out it as it is in example.
Example:
stringstrString1 = "abcd";
stringstrString2 = "dcba"; if (String.Compare(strString1, strString2) == 0) { // strString1 and strString2 are equal } else { // strString1 and strString2 are different }
Because strings used in example are diferrent, execution of our program will be continuing in section 'else'.
Comments
2012-01-23 11:09 | Comment this
Ruth:
Karla
Add your comment
|
List of articles
How to compare two Strings in C# Smart utilities |
Webdesign (c) 2009 - 2024 Supremus.sk |