Skip to main content
2 of 3
added 154 characters in 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 fixed:


If the size of the collection is dynamic:

dfhwze
  • 13.9k
  • 3
  • 38
  • 101