【发布时间】:2011-06-07 01:13:49
【问题描述】:
可能重复:
WCF DataMember EmitDefaultValue on value type? (but set my own default value)
考虑以下几点:
[DataContract]
public class MyType {
[DataMember(EmitDefaultValue = true)]
public string MyStr = "DefVal";
}
在上面的代码中,我可以指定赋值后使用的默认值。
现在考虑以下几点:
[DataContract]
public class MyType {
[DataMember(EmitDefaultValue = true)]
public string MyStr {
get { ... }
set { ... }
}
}
这里如何指定默认值???
谢谢
【问题讨论】:
标签: c# .net wcf web-services attributes