In a Class i have set of properties and i will be able to assign the values for some properties and some properties has default values. Now My case i want to remove those default value properties while returning the object response.
Example :
Public class Root {
public int intValue{get;set;}
public string strName{get;set;}
public string imgUrl{get;set}
public DateTime dtmCreated{get;set;}
public DateTime dtmExpiry{get;set;}
}
From above when i retrieve response i am seeing the imgurl as null & expiry date as default. i dont want to show those for some cases. how can i remove those properties from object while showing api response.
CodePudding user response:
int
and DateTime
can't "not have values". But their nullable counterparts can. If you want the properties to allow null values, make them nullable. For example:
public int? intValue { get; set; }