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; }
}

 

posted @ 2016-06-07 11:12  IsCarrie  阅读(2031)  评论(0编辑  收藏  举报