摘要: http://blog.sina.com.cn/s/blog_82526aa60100txtx.html在程序中经常碰到get、set,不甚明白,在网上查询时也说的迷迷糊糊,所以整理下,以学的明白透彻点。有两个类person:public class person{public string nam... 阅读全文
posted @ 2015-10-29 13:42 刘要直 阅读(103679) 评论(5) 推荐(11) 编辑
摘要: 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 6 namespace Test09 7 { 8 //class MyClass... 阅读全文
posted @ 2015-10-29 13:25 刘要直 阅读(567) 评论(0) 推荐(0) 编辑
摘要: 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 6 namespace Test08 7 { 8 class Program 9 {10... 阅读全文
posted @ 2015-10-29 12:50 刘要直 阅读(691) 评论(0) 推荐(0) 编辑
摘要: 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 6 namespace Test05 7 { 8 /// 9 /// 自定义类,封装加... 阅读全文
posted @ 2015-10-29 11:20 刘要直 阅读(1278) 评论(7) 推荐(0) 编辑
摘要: 从两者的声明上来看,公共字段只是类用public修饰符所公开的简单公共变量,而属性则是对字段的封装,它使用get和set访问器来控制如何设置或返回字段值。由于属性的实质是方法(get或set方法),在IL中是没有属性的概念的。所以对于开发过程中常用的赋值和取值操作来说,使用公共变量肯定会比使用属性速... 阅读全文
posted @ 2015-10-29 10:47 刘要直 阅读(10487) 评论(0) 推荐(2) 编辑