Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Applying EmitDefaultValue for a customised property

$
0
0

I have a DataMember defined as -

[DataMember(EmitDefaultValue = false)]
public int OccurNbr { get; set; }

OccurNbr can be 0, which is a valid value. But if we specify EmitDefaultValue=false, then the element will not be displayed in the JSON/XML. 

I do want to set a default value of OccurNbr, say -1 and will control the xml from displaying if the value is -1. 

I am currently working on C#5, can you please let me know if we can change the default value of .Net type int and force EmitDefaultvalue to apply the control on the

new default value rather than on 0 


Viewing all articles
Browse latest Browse all 9386

Trending Articles



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