Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Bool Array in C#
In a bool array, you can store true and false values. To set a bool array, use the new operator −
bool[] arr = new bool[5];
To add elements in the array −
arr[0] = true; arr[1] = true; arr[2] = false; arr[3] = true; arr[4] = true;
Let us see the complete code −
Example
using System;
public class Demo {
public static void Main() {
bool[] arr = new bool[5];
arr[0] = true;
arr[1] = true;
arr[2] = false;
arr[3] = true;
arr[4] = true;
Console.WriteLine("Displaying values...");
foreach (bool res in arr) {
Console.WriteLine(res);
}
}
}
Output
Displaying values... True True False True True
Advertisements
