c#attribute和property简易区分

来源:互联网 发布:评价毛新宇 知乎 编辑:程序博客网 时间:2024/05/22 14:34

c#Property和Attribute区别

property和attribute都有属性的意思,在xml和html、xaml中的属性都是attribute。

c#中一般property是属性,而attribute是特性的意思。

例如:

 public class Student    {        private string name;//字段        public string Name { get; set; }//property 属性    }
 [DataContract]//attribute 特性 public class Student{    [DataMember]//attribute 特性     public string Name{ get; set; }}
转自:http://www.cnblogs.com/yzw-carrie/p/5566324.html