[csharp] bool IsNumeric(Type type)
/*
"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));
} }
[csharp] bool IsNumeric(Type type)的更多相关文章
- XmlSerializer(Type type, Type[] extraTypes) 内存泄漏
在使用XmlSerializer进行序列化或者反序列的时候,对于下面的两个构造方法 XmlSerializer(Type)XmlSerializer.XmlSerializer(Type, Strin ...
- [terry笔记]IMPDP报错ORA-39083 Object type TYPE failed to create ORA-02304
今天在使用impdp导入的时候(同一数据库中转换schema),遇到了 ORA-39083: Object type TYPE failed to create with error: ORA-023 ...
- TypeError: Fetch argument 0 has invalid type <type 'int'>, must be a string or Tensor. (Can not convert a int into a Tensor or Operation.)
6月5日的時候,修改dilated_seg.py(使用tensorflow)出現了報錯: TypeError: Fetch argument 0 has invalid type <type ' ...
- Object type TYPE failed to create with error
ORA-39083: Object type TYPE failed to create with error: ORA-02304: invalid object identifier litera ...
- TypeError: Fetch argument None has invalid type <type 'NoneType'>
(fetch, type(fetch)))TypeError: Fetch argument None has invalid type <type 'NoneType'> 我的解决方案是 ...
- impdp报错ORA-39083 ORA-02304 Object type TYPE failed to create
环境Red Hat Enterprise Linux Server release 5.8 (Tikanga)ORACLE Release 11.2.0.3.0 Production 我用expdp, ...
- The entity type <type> is not part of the model for the current context
这是在网站里遇到的一个错误,自动生成的不能手动添加, reference: http://stackoverflow.com/questions/19695545/the-entity-type-xx ...
- python3运行报错:TypeError: Object of type 'type' is not JSON serializable解决方法(详细)
返回结果先转成str 字符创
- Object of type type is not JSON serializable
报这个错的原因是因为json.dumps函数发现字典里面有bytes类型的数据,无法编码.解决方法:将bytes类型的数据就把它转化成str类型. 定义dates[]后return JsonRespo ...
随机推荐
- 爬虫任务一:使用httpclient去爬取百度新闻首页的新闻标题和url,编码是utf-8
第一个入手的爬虫小任务: maven工程 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi=" ...
- ZeroMQ作者于昨天下午宣布选择安乐死
… printf("goodbye, world !");
- smtplib与email模块(实现邮件的发送)
SMTP是发送邮件的协议,Python内置对SMTP的支持,可以发送纯文本邮件.HTML邮件以及带附件的邮件. Python对SMTP支持有smtplib和email两个模块,email负责构造邮件, ...
- Spring 数据库连接池读取系统环境变量作为参数
原来是写在一个properties文件里面,后来项目要部署的的确太多了,每次更改不太方便,就想把这些固定不变的信息写在当地的环境变量里面 原先是这样的:引用的所有信息在jdbc.properties ...
- jquery关于select框的取值和赋值
jQuery("#select_id").change(function(){}); // 1.为Select添加事件,当选择其中一项时触发 var checkValue ...
- Boost scoped_ptr scoped_array 以及scoped_ptr与std::auto_ptr对比
boost::scoped_ptr和std::auto_ptr非常类似,是一个简单的智能指针,它能够保证在离开作用域后对象被自动释放.下列代码演示了该指针的基本应用: #include <str ...
- MySQL -表完整性约束(Day41)
阅读目录 一.介绍 二.not null 与 default 三.unique 四.primary key 五.auto_increment 六.foreign key 七. 总结 一 介绍 回到顶部 ...
- python识别验证码
1.tesseract-ocr安装 tesseract-ocr windows下载地址 http://digi.bib.uni-mannheim.de/tesseract/tesseract-ocr- ...
- Spark --idea无法new scala class
问题: 无法新建Scala class 解决: 1.下载插件 setting-->Plugins-->安装scala插件-->提示重启idea-->自动提示你安装scala s ...
- springmvc map
/** * 目标方法可以添加 Map 类型(实际上也可以是 Model 类型或 ModelMap 类型)的参数. * @param map * @return */ @RequestMapping(& ...