Test for equality between stings. : String Compare « Data Types « C# / C Sharp






Test for equality between stings.

    

using System;
using System.Text;

class StringApp {
    static void Main(string[] args) {
        string s1 = "Hello ";
        string s2 = "World!";
        Console.WriteLine("s1 == s2: {0}", s1 == s2);
        Console.WriteLine();

    }
}

   
    
    
  








Related examples in the same category

1.use the Equals() method and equality operator to check if two strings are equal
2.use the Compare() method to compare strings
3.Comparing a String to the Beginning or End of a Second StringComparing a String to the Beginning or End of a Second String
4.Compare stringsCompare strings
5.String copy and equalString copy and equal
6.Use String.Compare to check if a URI is a file URI
7.Sample for String.Compare(String, Int32, String, Int32, Int32, Boolean), ignore case
8.Sample for String.Compare(String, Int32, String, Int32, Int32, Boolean), Honor case
9.Check if a String contain another string by ignoring case
10.Compare two strings with StringComparison.CurrentCultureIgnoreCase
11.Checks if the string starts with special character. This does not include any special character from AllowedSpecialCharacters