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; }
}
原文地址:https://www.cnblogs.com/yzw-carrie/p/5566324.html