[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 ...
随机推荐
- Response 和 Request
1. request 对象和 response 对象均由服务器创建. 2. 服务器处理请求的流程: 服务器每次收到请求时, 都会为这个请求开辟一个新的线程; 服务器会把客户端的请求数据封装到 requ ...
- Php DOMDocument 中的 formatOutput
Nicely formats output with indentation and extra space 是否处理 缩进和多余的空白符
- vim批量注释与取消批量注释(转)
方法一 块选择模式 插入注释: 用v进入virtual(可视化)模式(可以省略这一步) 用上下键选中需要注释的行数 按ctrl+v进入可视化块模式 按大写I进入插入模式,输入注释符‘#’或者是‘//’ ...
- 微信小程序将带来web程序员的春天!
微信之父张小龙在年初那次演讲中曾表示:“我自己是很多年的程序员,我觉得我们应该为开发的团体做一些事情.”几个月后,微信正式推出微信应用号(即微信小程序)在互联网中掀起又一波热潮. 过去,对于很多开发者 ...
- 3. Longest Substring Without Repeating Characters(最长子串,双指针+hash)
Given a string, find the length of the longest substring without repeating characters. Examples: Giv ...
- @RequestBody和@ResponseBody的使用情形以及RestTemplate的http报文转换
@RequestBody和@ResponseBody两个注解,分别完成请求报文到对象和对象到响应报文的转换. @RequestBody 1.@requestBody注解常用来处理content-typ ...
- Linux x86架构下ACPI PNP Hardware ID的识别机制
转:https://blog.csdn.net/morixinguan/article/details/79343578 关于Hardware ID的用途,在前面已经大致的解释了它的用途,以及它和AC ...
- 什么时候需要用super
1.子类构造函数调用父类构造函数用super 2.子类重写(覆盖)父类方法后,若想调用父类中被重写的方法,用super 3.未被重写的方法可以直接调用.
- 20145235李涛《网络对抗》Exp8 Web基础
基础问答 什么是表单 可以收集用户的信息和反馈意见,是网站管理者与浏览者之间沟通的桥梁. 表单包括两个部分:一部分是HTML源代码用于描述表单(例如,域,标签和用户在页面上看见的按钮),另一部分是脚本 ...
- 20145109 实验二 Java面向对象程序设计
实验二 Java面向对象程序设计 实验内容 初步掌握单元测试和TDD 理解并掌握面向对象三要素:封装.继承.多态 初步掌握UML建模 熟悉S.O.L.I.D原则 了解设计模式 S.O.L.I.D原则: ...