- 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
What are Booleans types in C#?
For the Boolean type, the bool keyword is used and is an alias of System.Boolean.
It is used to declare variables to store the Boolean values, true and false.
Let us see an example to learn how to use bool in C#.
Example
using System; public class Demo { static void Main() { bool val = true; int d = DateTime.Now.DayOfYear; val = (d % 2 == 0); if (val) { Console.WriteLine("days: even number"); } else { Console.WriteLine("days:odd number"); } } }
Advertisements