Is there a C# equivalent to Java's Number class? -


i'm new c#, coming java, , i'd check whether object number (it can integer, double, float, etc). in java did saying if (toret instanceof number). i'm hoping there's similar c# thing if (toret number) far haven't been able find number class this. there way this, or have manually check integer, double, etc?

edit more info: want have byte array. however, when array stored in text file, parser i'm using can think it's integer array or double array. in java, had this:

jsonarray dblist = (jsonarray)result_; byte[] reallytoret = new byte[dblist.size()]; object tocomp = dblist.get(0);  if (tocomp instanceof number)     (int i=0; < dblist.size(); ++i) {         byte elem = ((number) dblist.get(i)).bytevalue();         reallytoret[i] = elem;     }      return reallytoret; } 

the important bit here if statement. objects in dblist parse integers, doubles, , bytes, care @ end byte value.

well, yeah, it's extension method ors possibilities.

this it:

public static bool isnumber(this object value) {     return value sbyte             || value byte             || value short             || value ushort             || value int             || value uint             || value long             || value ulong             || value float             || value double             || value decimal             || value biginteger; } 

and use this:

if (toret.isnumber()); 

this needs in static class.


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -