datamember

When to use DataContract and DataMember attributes?

放肆的年华 提交于 2019-11-26 02:27:04
问题 I am very confused about the DataContract attribute in WCF. As per my knowledge it is used for serializating user defined type like classes. I wrote one class which is exposed at client side like this. [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; } } It is working properly but when I remove DataContract and DataMember it