Looking for c# Keywords? Try Ask4Keywords

C# Language Частные поля


пример

Существуют два общих соглашения для частных полей: 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;
    }
}