C# | Check if two BitArray objects are equal Last Updated : 01 Feb, 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 BitArray object is equal to another BitArray 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# code to if specified // BitArray object is equal // to the current object using System; using System.Collections; class GFG { // Driver code public static void Main() { // Creating a BitArray BitArray myBitArr1 = new BitArray(4); // Creating a BitArray BitArray myBitArr2 = new BitArray(4); // Initializing values in myBitArr1 myBitArr1[0] = false; myBitArr1[1] = false; myBitArr1[2] = true; myBitArr1[3] = true; // Initializing values in myBitArr2 myBitArr2[0] = false; myBitArr2[2] = false; myBitArr2[1] = true; myBitArr2[3] = true; // using Equals(Object) method // to check if myBitArr1 is // equal to myBitArr2 or not Console.WriteLine(myBitArr1.Equals(myBitArr2)); } } Output: False Example 2: CSharp // C# code to if specified // BitArray object is equal // to the current object using System; using System.Collections; class GFG { // Driver code public static void Main() { // Creating a BitArray BitArray myBitArr1 = new BitArray(4); // Creating a BitArray BitArray myBitArr2 = new BitArray(4); // Initializing values in myBitArr1 myBitArr1[0] = false; myBitArr1[1] = false; myBitArr1[2] = true; myBitArr1[3] = true; // Initializing values in myBitArr2 myBitArr2[0] = false; myBitArr2[2] = false; myBitArr2[1] = true; myBitArr2[3] = true; // using Equals(Object) method // to check if myBitArr1 is // equal to myBitArr2 or not Console.WriteLine(myBitArr1.Equals(myBitArr2)); // Creating a BitArray BitArray myBitArr3 = new BitArray(4); // assigning myBitArr2 to myBitArr3 myBitArr3 = myBitArr2; // using Equals(Object) method // to check if myBitArr2 is // equal to myBitArr3 or not Console.WriteLine(myBitArr2.Equals(myBitArr3)); } } 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 BitArray objects are equal K Kirti_Mangal Follow Improve Article Tags : C# CSharp-method CSharp-Collections-Namespace CSharp-Collections-BitArray Similar Reads C# | Check if two ArrayList objects are equal Equals(Object) Method which is inherited from the Object class is used to check whether the specified ArrayList object is equal to another ArrayList 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 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 the BitArray is read-only The BitArray class manages a compact array of bit values, which are represented as Booleans, where true indicates that the bit is on i.e, 1 and false indicates the bit is off i.e, 0. This class is contained in System.Collections namespace. BitArray.IsReadOnly property is used to get a value indicati 2 min read C# | Copying BitArray elements to an Array The BitArray class manages a compact array of bit values, which are represented as Booleans, where true indicates that the bit is on i.e, 1 and false indicates the bit is off i.e, 0. This class is contained in System.Collections namespace. BitArray.CopyTo(Array, Int32) method is used to copy the ent 3 min read C# | Check if the BitArray is synchronized (thread safe) The BitArray class manages a compact array of bit values, which are represented as Booleans, where true indicates that the bit is on i.e, 1 and false indicates the bit is off i.e, 0. This class is contained in System.Collections namespace. BitArray.IsSynchronized property is used to get a value indi 2 min read 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 2 min read C# | Byte.Equals(Object) Method This method is used to get a value which indicates whether the current instance is equal to a specified object or not. Syntax: public override bool Equals (object obj); Here, it takes an object to compare with the current instance or null. Return Value: This method returns true if obj is an instance 2 min read C# | Number of elements contained in the BitArray The BitArray class manages a compact array of bit values, which are represented as Booleans, where true indicates that the bit is on i.e, 1 and false indicates the bit is off i.e, 0. This class is contained in System.Collections namespace. BitArray.Count property is used to get the number of element 2 min read C# | Check if two String objects have the same value | Set-1 String.Equals Method method is used to check whether the two String objects have the same value. This method can be overloaded by passing different numbers and types of parameters to it. There are total 5 methods in the overload list of this method in which the first 2 are discussed in this article 3 min read Like