What's the point of a DataContract in WCF?

前端 未结 6 1638
情歌与酒
情歌与酒 2020-12-07 14:07

VS.net creates a template when you create a WCF project.

It adds a class to the iService1.cs file:

// Use a data contract as illustrated in the sampl         


        
6条回答
  •  醉酒成梦
    2020-12-07 14:46

    There is another important use, You can change the Name of class and properties. It's a handy feature during serialization and deserialization.

    [DataContract(Name="EmployeeName")]
    public class Person
    {
       [DataMember(Name="FullName")]
       public string Name { get; set; }
    
       [DataMember(Name="HomeAddress")]
       public string Address { get; set; }
    }
    

提交回复
热议问题