Questions tagged «datamember»

7
何时使用DataContract和DataMember属性?
我DataContract对WCF中的属性感到非常困惑。据我所知,它用于序列化用户定义的类型(如类)。我写了一个这样的类,它在客户端公开。 [DataContract] public class Contact { [DataMember] public int Roll { get; set; } [DataMember] public string Name { get; set; } [DataMember] public string Address { get; set; } [DataMember] public int Age { get; set; } } 它工作正常,但是当我删除DataContract并且DataMember它也工作正常。我不明白为什么它可以正常工作。谁能告诉我的实际用途是DataContract什么? 我的服务合同如下所示 [ServiceContract] public interface IRestServiceImpl { [OperationContract] Contact XmlData(string id); …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.