Skip to main content
3 of 3
edited body
dfhwze
  • 13.9k
  • 3
  • 38
  • 101

I challenge the need for a list of booleans. There are alternatives available in the .NET Framework that deal with a sequence of booleans.


If the flags are static and fixed:

[Flags]
enum IGreetYou : uint
{
    None  = 0,
    Hi    = 1 << 0,
    Hello = 1 << 1,
    Yow   = 1 << 2
}

with a simple conversion to string as:

var value = IGreetYou.Hi | IGreetYou.Hello;
var asString = Convert.ToString((uint)value, 2);   // 11

If the size of the collection is dynamic:


If the size of the collection is fixed:

dfhwze
  • 13.9k
  • 3
  • 38
  • 101