Default value of bool in C#


Use the default operator to get the default value of bool type −

bool a = default(bool);

Above, we have used the default keyword to get the default value.

Let us see the code to display default value of bool −

Example

 Live Demo

using System;

public class Demo {
   public static void Main() {
      bool a = default(bool);
      // default for bool
      Console.WriteLine("Default for bool type = "+a);
   }
}

Output

The following is the output. It shows a blank space i.e. False.

Default for bool type = False

Updated on: 22-Jun-2020

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements