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:
using System;
using System.Collections;
class GFG {
public static void Main()
{
Queue q1 = new Queue();
q1.Enqueue(1);
q1.Enqueue(2);
q1.Enqueue(3);
q1.Enqueue(4);
Console.WriteLine(q1.Equals(q1));
}
}
|
Example 2:
using System;
using System.Collections;
class GFG {
public static void Main()
{
Queue q1 = new Queue();
q1.Enqueue( "C" );
q1.Enqueue( "C++" );
q1.Enqueue( "Java" );
q1.Enqueue( "C#" );
Queue q2 = new Queue();
q2.Enqueue( "HTML" );
q2.Enqueue( "CSS" );
q2.Enqueue( "PHP" );
q2.Enqueue( "SQL" );
Console.WriteLine(q1.Equals(q2));
Queue q3 = new Queue();
q3 = q2;
Console.WriteLine(q3.Equals(q2));
}
}
|
Last Updated :
28 Jan, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...