C# Single Equals(Single)
Description
Single Equals(Single)
returns a value indicating whether
this instance and a specified Single object represent the same value.
Syntax
Single.Equals(Single)
has the following syntax.
public bool Equals(
float obj
)
Parameters
Single.Equals(Single)
has the following parameters.
obj
- An object to compare with this instance.
Returns
Single.Equals(Single)
method returns true if obj is equal to this instance; otherwise, false.
Example
The following example reports that the Single value .3333 and the Single returned by dividing 1 by 3 are unequal.
/*w w w.j av a 2 s. c om*/
using System;
public class MainClass{
public static void Main(String[] argv){
float float1 = .33333f;
float float2 = 1/3;
// Compare them for equality
Console.WriteLine(float1.Equals(float2)); // displays false
}
}
The code above generates the following result.