Set default value in a DataContract?

后端 未结 2 1111
一向
一向 2020-12-30 01:58

How can I set a default value to a DataMember for example for the one shown below:

I want to set ScanDevice=\"XeroxScan\" by default

    [DataMember]         


        
2条回答
  •  别那么骄傲
    2020-12-30 02:42

    If you want it always to default to XeroxScan, why not do something simple like:

    [DataMember(EmitDefaultValue = false)]
    public string ScanDevice= "XeroxScan";
    

提交回复
热议问题