How to create and print a List of booleans with true or false in C#

1 Answer

0 votes
using System;
using System.Collections.Generic;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            List<bool> list = new List<bool>();
            list.Add(true);
            list.Add(true);
            list.Add(false);

            for (int i = 0; i < list.Count; i++)
            {
                Console.WriteLine($"index[{i}] = {list[i]}");
            }
        }
    }
}


/*
run:
      
index[0] = True
index[1] = True
index[2] = False

*/

 



answered Dec 26, 2016 by avibootz
...