C# loop over bool values
Correct syntax will be foreach
, not for
:
foreach (bool b in new [] { false, true }) {
/* ... */
}
While I think simply writing a parametrized function is definitely the correct approach, the closest to that C++11 syntax that you can get in C# would be:
foreach (bool value in new [] { false, true })
{
// ...
}