兰冰点点

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

随笔分类 -  c#

摘要:ref和out关键字都为引用类型,使用后都会修改实参的值 class Program { static void Main(string[] args) { int m = 10; int n; GetInt(ref m); GetInt2(out n) ; Console.WriteLine("m 阅读全文
posted @ 2021-04-15 10:24 兰冰点点 阅读(179) 评论(0) 推荐(0)

摘要:类中的变量成员,我们称之为:字段 一般实际运用中,我们应将字段设置成private,然后使用属性来访问 在类中,属性分为读取和写入两个操作 get { return xx; } set { xx = value; } 仅使用get代码块时,该属性是只读的 set代码块内可以对输入值进行过滤 if(v 阅读全文
posted @ 2021-04-14 17:45 兰冰点点 阅读(298) 评论(0) 推荐(0)

摘要:属性访问器格式 private int PetAge; public int Age { get { return PetAge; } set { PetAge = value; } } 属性访问器的作用:可以用于访问隐式或者受限制的字段,比直接使用字段更安全,方便维护,也更容易对数据进行检查 注: 阅读全文
posted @ 2021-04-14 17:23 兰冰点点 阅读(391) 评论(0) 推荐(0)