What does it mean to put a DataMemberAttribute on an interface member? How does this affect derived classes?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
The [DataMember] attribute, when applied to a member of a type, specifies that the member is part of a data contract. When this attribute is applied to a field or a property explicitly, it specifies that the member value will be serialized by an DataContractSerializer object (taken from Article)
In my case, I use this attributes with my WCF services. When I make an interface for a WCF Webservice I do it defining an interface in this way:
As you can see, the clien of this service will receive a POCOCLient class. Then I need to decorate the POCOClient class with the attributes you're asking form in this way in order to let the class to be serialized properly and send vía WCF.
As shown in the following signature, the DataMember attribute is not inheritable
Therefore, it makes very little sense to decorate interface members with this attribute as you will have to decorate the implementing classes' members with this attribute too.