摘要:ref和out关键字都为引用类型,使用后都会修改实参的值 class Program { static void Main(string[] args) { int m = 10; int n; GetInt(ref m); GetInt2(out n) ; Console.WriteLine("m
阅读全文
随笔分类 - c#
摘要:ref和out关键字都为引用类型,使用后都会修改实参的值 class Program { static void Main(string[] args) { int m = 10; int n; GetInt(ref m); GetInt2(out n) ; Console.WriteLine("m
阅读全文
摘要:类中的变量成员,我们称之为:字段 一般实际运用中,我们应将字段设置成private,然后使用属性来访问 在类中,属性分为读取和写入两个操作 get { return xx; } set { xx = value; } 仅使用get代码块时,该属性是只读的 set代码块内可以对输入值进行过滤 if(v
阅读全文
摘要:属性访问器格式 private int PetAge; public int Age { get { return PetAge; } set { PetAge = value; } } 属性访问器的作用:可以用于访问隐式或者受限制的字段,比直接使用字段更安全,方便维护,也更容易对数据进行检查 注:
阅读全文
|