User-1350042179 posted
Hi
I have the code.
[DataContract]
public class Employee
{
[DataMember(EmitDefaultValue = false)]
public string position {get; aet;}
[DataMember(EmitDefaultValue = false)]
public int salary {get; aet;}
[DataMember(EmitDefaultValue = false)]
public int? bonus {get; set;} = null
[DataMember(EmitDefaultValue = false)]
public int targetSalary {get; aet;}
}
I can see the null value in the result of bonus
I read this articule, tried to replicate it and it doesn't work:
https://docs.microsoft.com/en-us/dotnet/api/system.runtime.serialization.datamemberattribute.emitdefaultvalue?redirectedfrom=MSDN&view=netframework-4.7.2#System_Runtime_Serialization_DataMemberAttribute_EmitDefaultValue