Queue.Equals() Method in C#
Equals(Object) Method which is inherited from the Object class is used to check if a specified Queue class object is equal to another Queue class object or not. This method comes under the System.Collections namespace.
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 the above-discussed method:
Example 1:
// C# code to check if two Queue // class objects are equal or not using System; using System.Collections; class GFG { // Driver code public static void Main() { // Creating a Queue named q1 Queue q1 = new Queue(); // Adding elements to q1 q1.Enqueue(1); q1.Enqueue(2); q1.Enqueue(3); q1.Enqueue(4); // Checking whether q1 is // equal to itself or not Console.WriteLine(q1.Equals(q1)); } } |
True
Example 2:
// C# code to check if two Queue // class objects are equal or not using System; using System.Collections; class GFG { // Driver code public static void Main() { // Creating a Queue named q1 Queue q1 = new Queue(); // Adding elements to the Queue q1.Enqueue("C"); q1.Enqueue("C++"); q1.Enqueue("Java"); q1.Enqueue("C#"); // Creating a Queue named q2 Queue q2 = new Queue(); q2.Enqueue("HTML"); q2.Enqueue("CSS"); q2.Enqueue("PHP"); q2.Enqueue("SQL"); // Checking whether q1 is // equal to q2 or not Console.WriteLine(q1.Equals(q2)); // Creating a new Queue Queue q3 = new Queue(); // Assigning q2 to q3 q3 = q2; // Checking whether q3 is // equal to q2 or not Console.WriteLine(q3.Equals(q2)); } } |
False True
Recommended Posts:
- Difference between Method Overriding and Method Hiding in C#
- Decimal.Add() Method in C#
- C# | Clone() Method
- C# | Math.Pow() Method
- C# | Math.Exp() Method
- C# | Remove() Method
- C# | EndsWith() Method
- C# | PadRight() Method
- DateTimeOffset.Add() Method in C#
- C# | Uri.IsHexEncoding() Method
- Anonymous Method in C#
- C# | Replace() Method
- C# | Insert() Method
- C# | Join Method | Set - 2
- C# | IsNullOrWhiteSpace() Method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


