I am trying to parse a null from our api into an int like this:
API:
"thresholdMax": 10,
"thresholdAvg": null,
"thresholdMin": 40
Datamodel:
public int thresholdMax { get; set; }
public int thresholdAvg
{
get { return thresholdAvg; }
set
{
try
{
thresholdAvg = value;
}
catch
{
thresholdAvg = 0;
}
}
}
public int thresholdMin { get; set; }
But it fails saying it cannot parse null to int. I though however that with how I am setting these values, it should work.
What is the best practice, if I dont want to convert the type to string?