• How to validate an int variable return to an api ?

    SapnaVishwas Member

    How to validate an int variable return to an api ?

  • SapnaVishwas Member

    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
    }
    
  • Abhey Member

    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?

Viewing 2 reply threads
  • You must be logged in to reply to this topic.
en_USEnglish