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 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 Like