Quantcast
Channel: WCF, ASMX and other Web Services
Viewing all articles
Browse latest Browse all 555

Emitdefault = false doesn't work

$
0
0

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


Viewing all articles
Browse latest Browse all 555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>