locked
testing integer for value RRS feed

  • Question

  • I have an integer variable that I want to test for an empty value.

    Int32 medication_refills = 0;

    if ((medications_refills != null) && (medications_refills != 0)) ...

    This is in context of creating a HV Medication item.

    I understand that it throws an error on testing for null.

    Is it good enough for HV if I test just for 0?

    if (medications_refills != 0)

    Or, do I have to somehow test for a null value?

    If yes, then what's the proper way to do test an integer for a null value?

    Thanks,
    Gary
    Saturday, January 30, 2010 11:09 PM

Answers

  • integer values that are optional in HealthVault data types are stored as nullable integers (ie int?), so they support being set to null.

    Monday, February 1, 2010 5:04 PM

All replies

  • Hi Gary,

    In General, The default value for int  is 0 in c#, So you can check for  the below condition

    if(medications_refills != 0) and / or (medications_refills >0) .

    Health vault shell seems to be down at this point of time, I will update you regarding this issue further once the site is up.

    Regards,
    Madan Kamuju
    Monday, February 1, 2010 4:10 PM
  • integer values that are optional in HealthVault data types are stored as nullable integers (ie int?), so they support being set to null.

    Monday, February 1, 2010 5:04 PM