Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
これが有効でない理由を誰かが説明できますか? 「int から bool に変換できません」というメッセージが表示されます
if (b & 1)
また、なぜ私はできないのですか
b & 1
コードでは、これは正しい方法ですか?
int b = b & 1 if(b)
ありがとう!
これは、b & 1 の結果が整数であるためです (b が整数の場合)。
これを行う正しい方法は(特に)次のとおりです。
if ((b & 1) != 0) { ... }
また
if (Convert.ToBoolean(b & 1)) { ... }