/*
"C:\Program Files (x86)\MSBuild\14.0\Bin\csc.exe" /out:IsNumericType.exe IsNumericType.cs && start "IsNumericType.exe" IsNumericType.exe
IsNumeric(System.Boolean) -> False
IsNumeric(System.String) -> False
IsNumeric(System.Char) -> False
IsNumeric(System.Byte) -> True
IsNumeric(System.Byte[]) -> False
IsNumeric(System.DateTime) -> False
IsNumeric(System.Int32) -> True
IsNumeric(System.Single) -> True
IsNumeric(System.Decimal) -> True
IsNumeric(System.DayOfWeek) -> True
IsNumeric(System.Guid) -> False
IsNumeric(System.IntPtr) -> False
IsNumeric(System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=ne
utral, PublicKeyToken=b77a5c561934e089]]) -> False
IsNumeric(System.Action) -> False
Press any key to EXIT...
*/
using System;
using System.Reflection; static class Program {
static bool IsNumeric(Type type) {
switch (Type.GetTypeCode(type)) {
case TypeCode.Byte:
case TypeCode.SByte:
case TypeCode.UInt16:
case TypeCode.UInt32:
case TypeCode.UInt64:
case TypeCode.Int16:
case TypeCode.Int32:
case TypeCode.Int64:
case TypeCode.Decimal:
case TypeCode.Double:
case TypeCode.Single:
return true;
default:
return false;
}
} public static void Main() {
Test(typeof(bool));
Test(typeof(string));
Test(typeof(char));
Test(typeof(byte));
Test(typeof(byte[]));
Test(typeof(DateTime));
Test(typeof(int));
Test(typeof(float));
Test(typeof(Decimal));
Test(typeof(DayOfWeek));
Test(typeof(Guid));
Test(typeof(IntPtr));
Test(typeof(int?));
Test(typeof(Action));
Console.Write("Press any key to EXIT...");
Console.ReadKey(true);
} static void Test(Type type) {
Console.WriteLine("IsNumeric({0}) -> {1}", type.FullName, IsNumeric(type));
} }

最新文章

  1. 【原】IOS合并lib(.a)库的终极可用方法(可用于解决duplicate symbol静态库冲突)
  2. mysql count(*)和count(列)速率
  3. U-boot的环境变量值得注意的有两个: bootcmd 和bootargs
  4. Matlab 的reshape函数(转)
  5. PERCENT_RANK
  6. 【转】Dubbo是Alibaba开源的分布式服务框架
  7. Android 向系统添加一个联系人信息contact
  8. 简单的SqlHelper
  9. 获取ini文件所有的Sections和Keys
  10. Leetcode:minimum_depth_of_binary_tree解决问题的方法
  11. struts2 action 页面与action参数的传递的三种方式
  12. UVAlive-2554 Snakes & Ladders---BFS状态的存储
  13. C++:如何删除string对象的末尾非数字字符
  14. .net core 在网络高并发下提高JSON的处理效率
  15. 2019-01-28 [日常]Beyond的歌里最多是"唏嘘"吗? - Python分词+词频
  16. 基于MVC 的Quartz.Net组件实现的定时执行任务调度
  17. python基础一 ------如何获取多个字典相同的键
  18. Luogu4717 【模板】快速沃尔什变换(FWT)
  19. js字符串和数组
  20. Atom Editor 插件 atom-less 的使用方法

热门文章

  1. pip安装lxml报错 Fatal error in launcher: Unable to create process using '"c:\users\administrator\appdata\local\programs\python\python36\python.exe" "C:\Users\Administrator\AppData\L
  2. Django的模型层(1)- 单表操作(下)
  3. 008-shiro与spring web项目整合【二】认证、授权、session管理
  4. 收藏一些好用的c语言数据结构
  5. WebService SOAP WSDL UDDI 使用php的curl、PHP5的SoapClient实现同步
  6. vue组件的is特性
  7. 07 Spring框架 依赖注入(四)基于注解的依赖注入
  8. POJ 1659 Frogs' Neighborhood (Havel定理构造图)
  9. SSO 单点登录的实现原理
  10. case的嵌套使用