Fast Splash Screen in English Fast Splash Screen po Slovensky
Main page | C# section | VB6 section | PHP section | MySQL section |

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.

    stringstrString1 = "abcd";
    stringstrString2 = "dcba";

    if (String.Compare(strString1, strString2) == 0)
        // strString1 and strString2 are equal
        // strString1 and strString2 are different

Because strings used in example are diferrent, execution of our program will be continuing in section 'else'.

2012-01-23 11:09 | Comment this
SlovakRuth: Karla
Excellent post. You must continue to offer excellent resources and content like you have been offering. I will most likely stop by again in the future.

Add your comment
User language:



Human verification:
Number 162 is


List of articles

How to compare two Strings in C#
SharpDevelop - how to change 'File version'
How to delete file in C#
How to convert String to Int in C#
How to use Hexadecimal numbers in C#
How to convert Hex number to Int in C#

Smart utilities

Webdesign (c) 2009 - 2024