[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 ...
随机推荐
- HTTP 协议介绍
HTTP 协议规定了浏览器和服务器之间互相通信的规则. 请求协议: 规定了客户端发送给服务器的内容格式 响应协议: 服务器发送给客户端的内容格式 请求协议 请求协议格式: 请求行 多个请求头信息(属性 ...
- Codeforce 475 C. Kamal-ol-molk's Painting
从最左上的点開始枚举长宽.... C. Kamal-ol-molk's Painting time limit per test 2 seconds memory limit per test 256 ...
- 部门人员能力模型的思考:海军 or 海盗——By Me
我们欢迎您的加入,与我们一起推动安全可视化团队的成长,实现技术上共同进步和感情上的更多互相支持!
- 安装RabbitMQ3.6.10报错:{error,{missing_dependencies,[crypto,ssl],
参考https://blog.csdn.net/u010739551/article/details/80848993 如果安装上篇博文安装则可避免这种情况 CentOS6.7安装RabbitMQ3. ...
- laravel相关插件
1. Laravel-4-Generators Rapidly speed up your Laravel workflow with generators https://packagist.or ...
- Unity,android和IOS 防止八门神器注入
八门神器主要是不断筛选,来获取关键属性(比如金币)在内存中的地址,再根据该地址来修改指向的数据就可以成功. 因此,我们需要在金币读取和设置的时候,使用一个偏移量,来达到干扰的目的就可以了 未经仔细测试 ...
- Java并发之Semaphore的使用
Java并发之Semaphore的使用 一.简介 今天突然发现,看着自己喜欢的球队发挥如此的棒,然后写着博客,这种感觉很爽.现在是半场时间,就趁着这个时间的空隙,说说Java并发包中另外一个重量级的类 ...
- 构造函数与super
1. 当不定义构造方法,系统会为类隐式的创建一个空的无参构造方法 2. 当类定义了有参的构造方法,系统就不会为类创建无参构造方法 3. 子类中,若不显式调用super(), super()会被隐式调用 ...
- 20145229吴姗珊逆向BOF实践
20145229吴姗珊逆向BOF实践 实践 实践目标 本次实践的对象是一个名为pwn1的linux可执行文件 该程序正常执行流程是:main调用foo函数,foo函数会简单回显任何用户输入的字符串. ...
- NaviCat Primium远程连接Oracle 11g数据库操作方法
说明:作者使用的系统是windows 10 64位系统,使用的软件及插件都是基于64位系统进行安装.一. 软件准备 1.windows 10 64位 操作系统 2.NaviCat Primium 11 ...