0
 public class SomeClass
 {
    private readonly AuthenticationService _authenticationService = null;
    private readonly ProfileService _profileService = null;

    public SomeClass(IAuthenticationService authenticationService, ProfileService profileService)
    {
        _authenticationService = authenticationService;
        _bgMeterProfileService = bgMeterProfileService;
    }
   ...

プライベート変数に _varName を使用しています

これは、プライベート変数とコンストラクター パラメーターを区別するためです。

プライベート変数とメソッド パラメータを区別するより良い方法があるかどうかを確認するために、このコードを公開したいと考えました。

4

4 に答える 4

7

どうthis.variable = variable;ですか?

于 2013-04-03T12:14:13.587 に答える
1

私は_varName = varName;過去数年間 -convention を使用してきましたが、少なくとも次の数年間は、主に検出可能性 (インテリセンス)、デバッグ/読みやすさ (ローカル変数とのあいまいさを避けるため) の点で最も便利なように使用し続けます。

于 2013-04-03T12:19:48.817 に答える