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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM