C# | Check if a Hashtable is equal to another Hashtable Last Updated : 01 Feb, 2019 Comments Improve Suggest changes Like Article Like Report 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 some examples to understand the implementation in a better way: Example 1: CSHARP // C# code to check if a Hashtable is // equal to other Hashtable or not using System; using System.Collections; class GFG { // Driver code public static void Main() { // Creating a Hashtable Hashtable myTable = new Hashtable(); // Adding elements in Hashtable myTable.Add("g", "geeks"); myTable.Add("c", "c++"); myTable.Add("d", "data structures"); myTable.Add("q", "quiz"); // check if myTable is equal to myTable or not Console.WriteLine(myTable.Equals(myTable)); } } Output: True Example 2: CSHARP // C# code to check if a Hashtable is // equal to other Hashtable or not using System; using System.Collections; class GFG { // Driver code public static void Main() { // Creating 1st Hashtable Hashtable myTable1 = new Hashtable(); // Adding elements in Hashtable myTable1.Add("g", "geeks"); myTable1.Add("c", "c++"); myTable1.Add("d", "data structures"); myTable1.Add("q", "quiz"); // Creating 2nd Hashtable Hashtable myTable2 = new Hashtable(); // Adding elements in Hashtable myTable2.Add("G", "geeksforgeeks"); myTable2.Add("C", "C#"); myTable2.Add("d", "data structures"); myTable2.Add("q", "quiz"); // check if both the Hashtables // are equal or not Console.WriteLine(myTable1.Equals(myTable2)); } } Output: False Comment More infoAdvertise with us Next Article C# | Check if a Hashtable is equal to another Hashtable S Sahil_Bansall Follow Improve Article Tags : Misc C# CSharp-method CSharp-Collections-Hashtable CSharp-Collections-Namespace +1 More Practice Tags : Misc Similar Reads C# | Check if Hashtable has a fixed size Hashtable.IsFixedSize Property is used to get a value which indicates whether the Hashtable has a fixed size or not. Syntax: public virtual bool IsFixedSize { get; } Return Value: This property returns true if the Hashtable has a fixed size otherwise it returns false. The default is false. Below pro 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 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 Hashtable is read-only Hashtable.IsReadOnly property is used to get a value indicating whether the Hashtable is read-only or not. Syntax: public virtual bool IsReadOnly { get; } Return Value: This property returns true if the Hashtable is read-only otherwise it returns false. The default is false. Below programs illustrat 2 min read C# | Check if two SortedList objects are equal 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 2 min read C# | Check if the Hashtable contains a specific Key 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. Hashtable.ContainsKey(Object) Method is used to check whether the Hashtable contains a specific key or not. Syntax: public v 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 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 the Hashtable contains a specific Value 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. Hashtable.ContainsValue(Object) Method is used to check whether the Hashtable contains a specific value or not. Syntax: publ 2 min read C# | Copying the Hashtable elements to an Array Instance Hashtable.CopyTo(Array, Int32) Method is used to copy the elements of a Hashtable to a one-dimensional Array instance at the specified index.Syntax: public virtual void CopyTo (Array array, int arrayIndex); Parameters: array : The one-dimensional Array that is the destination of the DictionaryEntry 3 min read Like