I'd like to check if an object is a number so that .ToString()
would result in a string containing digits and +
,-
,.
Is it possible by simple type checking in .net (like: if (p is Number)
)?
Or Should I convert to string, then try parsing to double?
Update: To clarify my object is int, uint, float, double, and so on it isn't a string. I'm trying to make a function that would serialize any object to xml like this:
<string>content</string>
or
<numeric>123.3</numeric>
or raise an exception.
See Question&Answers more detail:os