In C# you write it like so:
bool b = (flag & a) != 0;
You can't assign an int to a bool in C#, like you can in C++.
(In C++ the compiler generates code that effectively does the same as the code above, although most C++ compilers will generate a warning if you just try to assign an int to a bool.)
Also see the Visual C++ warning C4800, which tells you to write it this way in C++ too.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…