C#判断奇偶数的函數
2016-01-12 16:53
471 查看
// 现代流行的"程序员" public static bool IsOdd(int n) { while (true) { switch (n) { case 1: return true; case 0: return false; } n -= 2; } } // 中规中矩的程序员 public static bool IsOdd(int n) { return (n % 2 == 1) ? true : false; } // 有经验的C#程序员 public static bool IsOdd(int n) { return Convert.ToBoolean(n % 2); } // 汇编程序员 public static bool IsOdd(int n) { return Convert.ToBoolean(n & 1); }
转载:
sono_yin的专栏 C#判断奇偶数的函數
相关文章推荐
- C#后台利用正则表达式查找匹配字符
- C# 多线程 Thread.Abort()
- C# Dictionary 的几种遍历方法
- C#四舍五入、上取整、下取整
- C#ref 使用
- C#获取josn串中某个对象的值
- C#设计模式02-抽象工厂模式(附源码)
- C# 各种数据类型的最大值和最小值常数
- C# 中关闭当前线程的四种方式
- c# 克隆
- 【小工具】将压缩包隐藏进图片中(C#源码,拖拽实现)
- web api中使用session的方法
- C#中HashTable的用法
- C#生成各种随机数 随机字母
- C#中的Dictionary字典类介绍
- C#索引器
- C# 哈希表Hashtable与字典表Dictionary<K,V>的比较。
- C#中Page执行顺序
- C# 引用的程序集没有强名称
- C# 生成仿京东页码条,服务器端实现