C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
C# String Equals()The C# Equals() method is used to check whether two specified String objects have the same value or not. If both strings have same value, it return true otherwise false. In other words, it is used to compare two strings on the basis of content. Signaturepublic bool Equals(String str) public static bool Equals(String, String) public override bool Equals(Object) public static bool Equals(String, String, StringComparison) public bool Equals(String, StringComparison) Parameterstr: it is a string object. ReturnIt returns boolean value either true or false. C# String Equals() Method Exampleusing System; public class StringExample { public static void Main(string[] args) { string s1 = "Hello"; string s2 = "Hello"; string s3 = "Bye"; Console.WriteLine(s1.Equals(s2)); Console.WriteLine(s1.Equals(s3)); } } Output: True False
Next TopicC# String Format()
|