C# | Check if two StringBuilder objects are Equal Last Updated : 03 May, 2022 Comments Improve Suggest changes Like Article Like Report StringBuilder.Equals Method is used to check whether this instance is equal to a specified object. Syntax: public bool Equals (System.Text.StringBuilder sb); Here, sb is an object to compare with this instance, or null. Return Value: It will return true if this instance and sb have an equal string, Capacity, and MaxCapacity values; otherwise, false. Example 1: csharp // C# program to if a StringBuilder object // is equal to another StringBuilder object using System; using System.Text; class Geeks { // Main Method public static void Main(String[] args) { // Create a StringBuilder object // with a String passed as parameter StringBuilder st1 = new StringBuilder("GeeksforGeeks"); // Checking whether st1 is // equal to itself or not Console.WriteLine(st1.Equals(st1)); } } Output:True Example 2: csharp // C# program to if a StringBuilder object // is equal to another StringBuilder object using System; using System.Text; class Geeks { // Main Method public static void Main(String[] args) { // Create a StringBuilder object // with a String passed as parameter StringBuilder st1 = new StringBuilder("GeeksforGeeks"); // Create a StringBuilder object // with a String passed as parameter StringBuilder st2 = new StringBuilder("GFG"); // Checking whether st1 is // equal to st2 or not Console.WriteLine(st1.Equals(st2)); // Create a StringBuilder object // with a String passed as parameter StringBuilder st3 = new StringBuilder(); // Assigning st2 to st3 st3 = st2; // Checking whether st3 is // equal to st2 or not Console.WriteLine(st3.Equals(st2)); } } Output:False True Reference: https://docs.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.equals?view=netcore-2.2 Comment More infoAdvertise with us Next Article C# | Check if two StringBuilder objects are Equal K Kirti_Mangal Follow Improve Article Tags : C# CSharp-method CSharp-StringBuilder-Class Similar Reads C# | Check if two StringCollection objects are equal Equals(Object) Method which is inherited from the Object class is used to check if a specified StringCollection object is equal to another StringCollection object or not. Syntax: public virtual bool Equals (object obj); Here, obj is the object which is to be compared with the current object. Return 2 min read C# | Check if two StringDictionary objects are equal or not Equals(Object) Method which is inherited from the Object class is used to check if a specified StringDictionary object is equal to another StringDictionary object or not. Syntax: public virtual bool Equals (object obj); Here, obj is the object which is to be compared with the current object. Return 2 min read C# | Check if two ArrayList objects are equal Equals(Object) Method which is inherited from the Object class is used to check whether the specified ArrayList object is equal to another ArrayList object or not. Syntax: public virtual bool Equals (object obj); Here, obj is the object which is to be compared with the current object. Return Value: 2 min read C# | Check if two HashSet<T> objects are equal Equals(Object) Method which is inherited from the Object class is used to check if a specified HashSet<T> object is equal to another HashSet<T> object or not. Syntax: public virtual bool Equals (object obj); Here, obj is the object which is to be compared with the current object. Return 2 min read Check if Two Dictionary Objects are Equal in C# In C#, a Dictionary<TKey, TValue> is a collection of key-value pairs. When we work with dictionaries, we may need to check if two dictionaries are equal. This means they contain the exact same keys and values.In this article, we are going to learn how to check dictionary equality both by refer 3 min read C# | Check if two String objects have the same value | Set-1 String.Equals Method method is used to check whether the two String objects have the same value. This method can be overloaded by passing different numbers and types of parameters to it. There are total 5 methods in the overload list of this method in which the first 2 are discussed in this article 3 min read C# | Check if an array object is equal to another array object An array is a group of like-typed variables that are referred to by a common name. And each data item is called an element of the array. Equals(Object) method which is inherited by Array class from object class is used to check whether an array is equal to another array or not. Syntax: public virtua 2 min read C# | Check if a Hashtable is equal to another Hashtable The Hashtable class represents a collection of key-and-value pairs that are organized based on the hash code of the key. The key is used to access the items in the collection. Syntax: myTable1.Equals(myTable2) Here, myTable1 and myTable2 are the two Hashtables which is to be checked. Below given are 2 min read C# Program to Check Given Strings are Equal or Not Using equal to (==) Operator Given two strings we need to check if they are equal by using the == operator. The == Operator compares the reference identity i.e. whether they are referring to the same identity in the heap. If they are equal then it will return true, otherwise, return false. Example: Input String 1 : geeks String 2 min read C# | Equals(String, String) Method In C#, Equals(String, String) is a String method. It is used to determine whether two String objects have the same value or not. Basically, it checks for equality. If both strings have the same value, it returns true otherwise returns false. This method is different from Compare and CompareTo method 2 min read Like