Default value of bool in C#

CsharpProgrammingServer Side Programming

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
raja
Published on 04-Sep-2018 10:48:46
Advertisements