C# Single Equals(Object)
Description
Single Equals(Object)
returns a value indicating whether
this instance is equal to a specified object.
Syntax
Single.Equals(Object)
has the following syntax.
public override bool Equals(
Object obj
)
Parameters
Single.Equals(Object)
has the following parameters.
obj
- An object to compare with this instance.
Returns
Single.Equals(Object)
method returns true if obj is an instance of Single and equals the value of 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.
//ww w . ja v a2s . c o m
using System;
public class MainClass{
public static void Main(String[] argv){
float float1 = .33333f;
object float2 = 1/3;
// Compare them for equality
Console.WriteLine(float1.Equals(float2)); // displays false
}
}
The code above generates the following result.