- 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.ToBoolean Method in C#
The Convert.ToBoolean method is used to convert a specified value to an equivalent Boolean value.
The following is our double type.
double doubleNum = 329.34;
To convert it to Boolean, use the Convert.ToBoolean() method.
bool boolNum; boolNum = System.Convert.ToBoolean(doubleNum);
Let us see another example.
Example
using System; public class Demo { public static void Main() { double doubleNum = 3.4; bool boolNum; // Double to bool boolNum = System.Convert.ToBoolean(doubleNum); System.Console.WriteLine("{0} as a Boolean = {1}.", doubleNum, boolNum); } }
Output
3.4 as a Boolean = True.
Advertisements