Booleans
Boolean data type represents two logical values true
and false
. The keyword bool
can be used to create a Boolean variable:
main.cs
12345678910111213141516using System; namespace ConsoleApp { internal class Program { static void Main(string[] args) { bool isOnline = true; Console.WriteLine(isOnline); // Output: True isOnline = false; Console.WriteLine(isOnline); // Output: False } } }
Logical values are used especially where we want to execute a piece of code based on a specific condition. We will learn more about conditional statements in the next section.
Kiitos palautteestasi!
Kysy tekoälyä
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme
Awesome!
Completion rate improved to 1.59
Booleans
Pyyhkäise näyttääksesi valikon
Boolean data type represents two logical values true
and false
. The keyword bool
can be used to create a Boolean variable:
main.cs
12345678910111213141516using System; namespace ConsoleApp { internal class Program { static void Main(string[] args) { bool isOnline = true; Console.WriteLine(isOnline); // Output: True isOnline = false; Console.WriteLine(isOnline); // Output: False } } }
Logical values are used especially where we want to execute a piece of code based on a specific condition. We will learn more about conditional statements in the next section.
Kiitos palautteestasi!