CSharp examples for System.Reflection:Type
Is Number Type
using System.Threading.Tasks; using System.Text; using System.Runtime.Serialization; using System.Runtime.CompilerServices; using System.Reflection.Emit; using System.Reflection; using System.Linq; using System.IO;/* w w w. j a v a 2s . c o m*/ using System.Globalization; using System.Collections.Generic; using System; public class Main{ public static bool IsNumberType(this Type t) { return t.IsIntegerNumberType() || t.IsFloatingPointNumberType(); } public static bool IsFloatingPointNumberType(this Type t) { return t == typeof(float) || t == typeof(double) || t == typeof(decimal); } public static bool IsIntegerNumberType(this Type t) { return t == typeof(byte) || t == typeof(sbyte) || t == typeof(short) || t == typeof(ushort) || t == typeof(int) || t == typeof(uint) || t == typeof(long) || t == typeof(ulong); } }