C# String Equals() Method

You are Here:

C# String Equals()

The Equals() method checks whether the two specified String objects have the same value or not.

Note: Both, == and Equals() method compares the content of strings. So, there is no difference between them.


C# Compiler
using System; namespace myApp { class Program { static void Main(string[] args) { string s1 = "JOHN DOE"; string s2 = "john doe"; string s3 = "JOHN DOE"; Console.WriteLine(s1.Equals(s2)); Console.WriteLine(s1.Equals(s3)); } } }


False True


public bool s1.Equals(s2)

Parameter Values

s1RequiredSpecifies the string to be compared.
s2RequiredSpecifies the string to be compared.

Return Value

TrueIf the two specified String objects have the same value.
FalseIf the two specified String objects does not have the same value.


Hi Developers, we almost covered 90% of String functions and Interview Question on C# with examples for quick and easy learning.

We are working to cover every Single Concept in C#.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author