- 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
Convert.ToSingle Method in C#
Convert a specified value to a single-precision floating-point number using the Convert.ToSingle() method in C#.
Here is our bool −
bool boolVal = false;
Now, let us use the ToSingle() method to convert the value to a single precision floating-point.
float floatVal; floatVal = Convert.ToSingle(boolVal);
Example
using System; public class Demo { public static void Main() { bool boolVal = false; float floatVal; floatVal = Convert.ToSingle(boolVal); Console.WriteLine("Converted {0} to {1}", boolVal, floatVal); } }
Output
Converted False to 0
Advertisements