Console.WriteLine Method (Boolean)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Writes the text representation of the specified Boolean value, followed by the current line terminator, to the standard output stream.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

[HostProtectionAttribute(SecurityAction.LinkDemand, UI = true)]
public static void WriteLine(
	bool value


Type: System.Boolean

The value to write.

Exception Condition

An I/O error occurred.

The text representation of value is produced by calling the Boolean.ToString method.

For more information about the line terminator, see the Remarks section of the WriteLine method that takes no parameters.

The following example generates ten random integers and uses the Console.WriteLine(Boolean) method to indicate whether they are even.

using System;

public class Example
   public static void Main()
      // Assign 10 random integers to an array.
      Random rnd = new Random();
      int[] numbers = new int[10]; 
      for (int ctr = 0; ctr <= numbers.GetUpperBound(0); ctr++)
         numbers[ctr] = rnd.Next();

      // Determine whether the numbers are even or odd.
      foreach (var number in numbers) {
         bool even = (number % 2 == 0);
         Console.WriteLine("Is {0} even:", number);


for modifying safe top-level windows and subwindows. Associated enumeration: UIPermissionWindow.SafeTopLevelWindows

.NET Framework
Available since 1.1
Return to top