且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用C#查找数字是偶数还是奇数?

更新时间:2023-02-09 19:38:44

这可能算作作弊,但如果您使用 BigInteger,它有一个 IsEven 方法.

It may count as cheating, but if you use BigInteger, it has an IsEven method.

如MSDN所述,调用此方法相当于:

As stated in MSDN, calling this method is equivalent to:

value % 2 == 0;

参考: