This method indicates whether an object is numeric or not. Handy in reflection type situations when you need to perform and action based on type.private static bool IsNumeric(Object o){ if((o is int) || (o is int?) || (o is decimal) || (o is decimal?) || (o is double) || (o is double?) || (o is float) || (o is float?) || (o is long) || (o is long?) || (o is ulong) || (o is ulong?) || (o is ushort) || (o is ushort?) || (o is short) || (o is short?) || (o is byte) || (o is byte?) || (o is sbyte) || (o is sbyte?) || (o is uint) || (o is uint?)) return true; return false;}
This method indicates whether an object is numeric or not. Handy in reflection type situations when you need to perform and action based on type.
private static bool IsNumeric(Object o){ if((o is int) || (o is int?) || (o is decimal) || (o is decimal?) || (o is double) || (o is double?) || (o is float) || (o is float?) || (o is long) || (o is long?) || (o is ulong) || (o is ulong?) || (o is ushort) || (o is ushort?) || (o is short) || (o is short?) || (o is byte) || (o is byte?) || (o is sbyte) || (o is sbyte?) || (o is uint) || (o is uint?)) return true; return false;}
It's long and a bit ugly but it's the only way I've found.
Remember Me