The Way to Programming
The Way to Programming
How to validate an int variable return to an api ?
It would help if we had a little of your code to see how the return is handled.
object myMostExcellentInteger = 5; int myInteger = int.MinValue; if (int.TryParse(myMostExcellentInteger.ToString(), out myInteger)) { // Run some excellent code }
The 3rd party returns an object that I instantiated. All values returned are stored in this object’s property. I think your example code is good enough. But my question is also that if this property type is of “int” type then do I still need to check using your example? I mean, C# is strong type so wouldn’t it already throw an exception if I’m getting non-integer or script embedded value in an int property field?
Sign in to your account