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 some examples to understand the implementation in a better way:
Example 1:
using System;
using System.Collections;
class GFG {
public static void Main()
{
Hashtable myTable = new Hashtable();
myTable.Add( "g" , "geeks" );
myTable.Add( "c" , "c++" );
myTable.Add( "d" , "data structures" );
myTable.Add( "q" , "quiz" );
Console.WriteLine(myTable.Equals(myTable));
}
}
|
Example 2:
using System;
using System.Collections;
class GFG {
public static void Main()
{
Hashtable myTable1 = new Hashtable();
myTable1.Add( "g" , "geeks" );
myTable1.Add( "c" , "c++" );
myTable1.Add( "d" , "data structures" );
myTable1.Add( "q" , "quiz" );
Hashtable myTable2 = new Hashtable();
myTable2.Add( "G" , "geeksforgeeks" );
myTable2.Add( "C" , "C#" );
myTable2.Add( "d" , "data structures" );
myTable2.Add( "q" , "quiz" );
Console.WriteLine(myTable1.Equals(myTable2));
}
}
|
Last Updated :
01 Feb, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...