- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Single.Equals() Method in C# with Examples
The Single.Equals() method in C# is used to return a value indicating whether two instances of Single represent the same value.
Syntax
public bool Equals (float ob); public override bool Equals (object ob);
The parameter ob for the both the syntaxes is an object to compare with this instance.
Example
using System; public class Demo { public static void Main() { float f1 = 15.9f; float f2 = 40.2f; Console.WriteLine("Value1 = "+f1); Console.WriteLine("Value2 = "+f2); Console.WriteLine("Are both the values equal? = "+f1.Equals(f2)); } }
Output
Value1 = 15.9 Value2 = 40.2 Are both the values equal? = False
Example
using System; public class Demo { public static void Main() { float f1 = 10.9f; object f2 = 10.9f; Console.WriteLine("Value1 = "+f1); Console.WriteLine("Value2 = "+f2); Console.WriteLine("Are both the values equal? = "+f1.Equals(f2)); } }
Output
Value1 = 10.9 Value2 = 10.9 Are both the values equal? = True
Advertisements