C# | Check if two List objects are equal Last Updated : 27 Jan, 2019 Comments Improve Suggest changes Like Article Like Report 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: This method return true if the specified object is equal to the current object otherwise it returns false. Below programs illustrate the use of above-discussed method: Example 1: CSharp // C# program to if a List object // is equal to another List object using System; using System.Collections.Generic; class Geeks { // Main Method public static void Main(String[] args) { // Creating an List<T> of Integers List<int> firstlist = new List<int>(); // Adding elements to List firstlist.Add(17); firstlist.Add(19); firstlist.Add(21); firstlist.Add(9); firstlist.Add(75); firstlist.Add(19); firstlist.Add(73); // Checking whether firstlist is // equal to itself or not Console.WriteLine(firstlist.Equals(firstlist)); } } Output: True Example 2: CSharp // C# program to if a List object // is equal to another List object using System; using System.Collections.Generic; class Geeks { // Main Method public static void Main(String[] args) { // Creating a List of strings List<string> list1 = new List<string>(); // Inserting elements in List list1.Add("DS"); list1.Add("C++"); list1.Add("Java"); list1.Add("JavaScript"); // Creating an List<T> of Integers List<int> list2 = new List<int>(); // Adding elements to List list2.Add(78); list2.Add(44); list2.Add(27); list2.Add(98); list2.Add(74); // Checking whether list1 is // equal to list2 or not Console.WriteLine(list1.Equals(list2)); // Creating a List of integers List<int> list3 = new List<int>(); // Assigning list2 to list3 list3 = list2; // Checking whether list3 is // equal to list2 or not Console.WriteLine(list3.Equals(list2)); } } 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 List objects are equal K Kirti_Mangal Follow Improve Article Tags : C# CSharp-method CSharp-Generic-List CSharp-Generic-Namespace Similar Reads C# | Check if two ListDictionary objects are equal Equals(Object) Method which is inherited from the Object class is used to check if a specified ListDictionary object is equal to another ListDictionary 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 Valu 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 C# | Check if two LinkedList<T> objects are equal Equals(Object) Method which is inherited from the Object class is used to check if a specified LinkedList<T> object is equal to another LinkedList<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. R 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 Like