Neat code to convert bool[] -> "false, true, true, false"
How about:
String.Join(", ", new List<Boolean>() { true, false, false, true }.ConvertAll(x => x.ToString()).ToArray())
var array = new[] { true, false, false };
var result = string.Join(", ", array.Select(b => b.ToString()).ToArray());
Console.WriteLine(result);
arrayOfBools.Select(x => x.ToString()).Aggregate((x, y) => x + ", " + y)
If you are using .NET 4, the following line is enough, because String.Join<T>
internally calls the ToString()
-method for every item.
Console.WriteLine(string.Join(", ", new[] { false, true, true, false }));
>>>> False, True, True, False