Open oOtroyOo opened 3 years ago
I think the best way is to as Nullable
public class Test
{
[IgnoreDataMember]
public int Num { get; set; }
[DataMember(Name = "num")]
public int? RealNum
{
get
{
return this.Num;
}
set
{
this.Num = value.GetValueOrDefault();
}
}
}
For example. We have some apis like this
And I have a type contains
int num;
But some how,(due to server developing which I'm uncertain), our srever could possible to return value suchas
then my client will throw a Exception. I don't want to change all my types into nullable values , suchas
int? num
, By fix this issue , I changed codes follows:The purpose is to check the value is
null
, so i can skip this value by defualt .Is there a better way to solve the issue ?