C#语言私有字段
示例
私有字段有两种常用约定:camelCase和_camelCaseWithLeadingUnderscore。
骆驼香烟盒
public class Rational
{
private readonly int numerator;
private readonly int denominator;
public Rational(int numerator, int denominator)
{
// "this" keyword is required to refer to the class-scope field
this.numerator= numerator;
this.denominator= denominator;
}
}带下划线的驼色表壳
public class Rational
{
private readonly int _numerator;
private readonly int _denominator;
public Rational(int numerator, int denominator)
{
// Names are unique, so "this" keyword is not required
_numerator = numerator;
_denominator = denominator;
}
}
热门推荐
10 祝女儿简短祝福语大全
11 大学新年祝福语简短创意
12 元旦适合的祝福语简短
13 朋友出远门祝福语简短
14 初六简短的祝福语
15 祝男孩生日祝福语简短
16 同事调离的祝福语简短
17 拜年红包的祝福语简短
18 妈妈生日祝福语简短励志