How to create a list with Boolean values 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(false);
            list.Add(true);
            list.Add(false);

            foreach (bool val in list) {
                Console.WriteLine(val);
            }
        }
    }
}


/*
run:
      
True
False
True
False
  
*/

 



answered Aug 4, 2018 by avibootz

Related questions

1 answer 139 views
139 views asked Feb 11, 2024 by avibootz
2 answers 246 views
2 answers 252 views
1 answer 170 views
170 views asked Nov 15, 2021 by avibootz
1 answer 162 views
3 answers 234 views
234 views asked Jan 2, 2017 by avibootz
...