Single.Equals() Method in C# with Examples Last Updated : 01 May, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report Single.Equals() Method is used to get a value which indicates whether the two instances of Single represents the same value or not. There are 2 methods in the overload list of this method as follows: Equals(Single) Method Equals(Object) Method Single.Equals(Single) Method This method is used to return a value indicating whether this instance and a specified Single object represent the same value. Syntax: public bool Equals (float obj); Here, it takes a Single object to compare to this instance. Return Value: This method returns true if obj is equal to this instance otherwise, false. Below programs illustrate the use of Single.Equals() Method: Example 1: csharp // C# program to demonstrate the // Single.Equals(Single) Method using System; using System.Globalization; class GFG { // Main Method public static void Main() { // Declaring and initializing value1 float value1 = 10.5f; // Declaring and initializing value2 float value2 = 20.6f; // using Equals(Single) method bool status = value1.Equals(value2); // checking the status if (status) Console.WriteLine("{0} is equal to {1}", value1, value2); else Console.WriteLine("{0} is not equal to {1}", value1, value2); } } Output: 10.5 is not equal to 20.6 Example 2: csharp // C# program to demonstrate the // Single.Equals(Single) Method using System; using System.Globalization; class GFG { // Main Method public static void Main() { // calling get() method get(5f, 5f); get(5.5f, 4.5f); get(10f, 10f); get(7.5f, 19.5f); } // defining get() method public static void get(float value1, float value2) { // using Equals(Single) method bool status = value1.Equals(value2); // checking the status if (status) Console.WriteLine("{0} is equal to {1}", value1, value2); else Console.WriteLine("{0} is not equal to {1}", value1, value2); } } Output: 5 is equal to 5 5.5 is not equal to 4.5 10 is equal to 10 7.5 is not equal to 19.5 Single.Equals(Object) Method This method is used to returns a value indicating whether this instance is equal to a specified object or not. Syntax: public override bool Equals (object obj); Here, it takes an object to compare with this instance. Return Value: This method returns true if obj is an instance of Single and equals the value of this instance otherwise, false. Below programs illustrate the use of the above-discussed method: Example 1: csharp // C# program to demonstrate the // Single.Equals(Single) Method using System; using System.Globalization; class GFG { // Main Method public static void Main() { // Declaring and initializing value1 float value1 = 10.5f; // Declaring and initializing value2 object value2 = 3 / 36; // using Equals(object) method bool status = value1.Equals(value2); // checking the status if (status) Console.WriteLine("{0} is equal to {1}", value1, value2); else Console.WriteLine("{0} is not equal to {1}", value1, value2); } } Output: 10.5 is not equal to 0 Example 2: csharp // C# program to demonstrate the // Single.Equals(object) Method using System; using System.Globalization; class GFG { // Main Method public static void Main() { // calling get() method get(5f, new Object()); get(5.5f, (float)5.5); get(10f, 10); get(7.5f, 2 / 5); } // defining get() method public static void get(float value1, object value2) { // compare both float value // using Equals(object) method bool status = value1.Equals(value2); // checking the status if (status) Console.WriteLine("{0} is equal to {1}", value1, value2); else Console.WriteLine("{0} is not equal to {1}", value1, value2); } } Output: 5 is not equal to System.Object 5.5 is equal to 5.5 10 is not equal to 10 7.5 is not equal to 0 Reference: https://docs.microsoft.com/en-us/dotnet/api/system.single.equals?view=netstandard-2.1 Comment More infoAdvertise with us Next Article Single.Equals() Method in C# with Examples R rohitprasad3 Follow Improve Article Tags : C# CSharp-method CSharp-Single-Struct Similar Reads SByte.Equals Method in C# with Examples SByte.Equals Method is used to get a value which indicates whether the current instance is equal to a specified object or SByte or not. There are 2 methods in the overload list of this method as follows: Equals(SByte) Method Equals(Object) Method SByte.Equals(SByte) Method This method is used to ret 3 min read UInt32.Equals Method in C# with Examples UInt32.Equals Method is used to get a value which indicates whether the current instance is equal to a specified object or 32-bit unsigned integer or not. There are 2 methods in the overload list of this method as follows: Equals(UInt32) Method Equals(Object) Method UInt32.Equals(UInt32) Method This 3 min read UInt16.Equals Method in C# with Examples UInt16.Equals Method is used to get a value which indicates whether the current instance is equal to a specified object or 16-bit unsigned integer or not. There are 2 methods in the overload list of this method as follows: Equals(UInt16) Method Equals(Object) Method UInt16.Equals(UInt16) Method This 3 min read UInt64.Equals Method in C# with Examples UInt64.Equals Method is used to get a value which indicates whether the current instance is equal to a specified object or 64-bit unsigned long integer or not. There are 2 methods in the overload list of this method as follows: Equals(UInt64) Method Equals(Object) Method UInt64.Equals(UInt64) Method 3 min read Int16.Equals Method in C# with Examples Int16.Equals() Method is used to get a value which indicates whether the current instance is equal to a specified object or Int16. There are 2 methods in the overload list of this method which are as follows: Equals(Int16) Method Equals(Object) Method Int16.Equals(Int16) This method is used to retur 4 min read Like