C# | Check if two SortedList objects are equal Last Updated : 17 Dec, 2018 Comments Improve Suggest changes Like Article Like Report Equals(Object) Method which is inherited from the Object class is used to check whether the specified SortedList object is equal to another SortedList 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: This method return true if the specified object is equal to the current object otherwise, false. Below programs illustrate the use of above-discussed method: Example 1: CSharp // C# program to if a SortedList // is equal to another SortedList using System; using System.Collections; class Geeks { // Main Method public static void Main(String[] args) { // Creating a sorted list of key/value pairs SortedList fslist = new SortedList(); // Adding pairs to fslist fslist.Add("Maths ", 98); fslist.Add("English ", 99); fslist.Add("Physics ", 97); fslist.Add("Chemistry", 96); fslist.Add("CSE ", 100); // Checking whether fslist is // equal to itself or not Console.WriteLine(fslist.Equals(fslist)); } } Output: True Example 2: CSharp // C# program to if a SortedList // is equal to another SortedList using System; using System.Collections; class Geeks { // Main Method public static void Main(String[] args) { // Creating a sorted list of key/value pairs SortedList fslist = new SortedList(); // Adding pairs to fslist fslist.Add("Maths ", 98); fslist.Add("English ", 99); fslist.Add("Physics ", 97); fslist.Add("Chemistry", 96); fslist.Add("CSE ", 100); // Creating an SortedList SortedList fslist2 = new SortedList(); // Adding elements to SortedList fslist2.Add("1", "one"); fslist2.Add("2", "two"); fslist2.Add("3", "three"); fslist2.Add("4", "four"); fslist2.Add("5", "five"); // Checking whether fslist is // equal to fslist2 or not Console.WriteLine(fslist.Equals(fslist2)); // Creating a sorted list of key/value pairs SortedList fslist3 = new SortedList(); // Assigning fslist2 to fslist3 fslist3 = fslist2; // Checking whether fslist3 is // equal to fslist2 or not Console.WriteLine(fslist3.Equals(fslist2)); } } Output: False True Note: If the current instance is a reference type, the Equals(Object) method checks for reference equality. Comment More infoAdvertise with us Next Article C# | Check if two SortedList objects are equal K Kirti_Mangal Follow Improve Article Tags : C# CSharp-method CSharp-Collections-Namespace CSharp-Collections-SortedList Similar Reads C# | Check if two SortedSet<T> objects are equal Equals(Object) Method which is inherited from the Object class is used to check if a specified SortedSet<T> object is equal to another SortedSet<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. Ret 2 min read C# | Check if two Tuple Objects are equal A tuple is a data structure which gives you the easiest way to represent a data set. You can also check if the given tuple object is equal to the specified object or not using the Equals Method. This method will return true if the given tuple object is equal to the specified object, otherwise, retur 2 min read Check if two SortedDictionary objects are equal in C# Equals(Object) Method which is inherited from the Object class is used to check if a specified SortedDictionary object is equal to another SortedDictionary 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 OrderedDictionary objects are equal Equals(Object) Method which is inherited from the Object class is used to check if a specified OrderedDictionary object is equal to another OrderedDictionary object or not. Syntax: public virtual bool Equals (object obj); Here, obj is the object which is to be compared with the current object. Retur 2 min read C# | Check if two List objects are equal Equals(Object) Method which is inherited from the Object class is used to check if a specified List<T> object is equal to another List<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 Value: 2 min read Like