What for should I mark private variables as private if they already are?

前端 未结 10 1797
星月不相逢
星月不相逢 2021-01-06 18:43

As far as I know, in C# all fields are private for default, if not marked otherwise.

class Foo
{
  private string bar;
}

class Foo
{
  string bar;
}
         


        
10条回答
  •  自闭症患者
    2021-01-06 19:33

    I think for readability it is always best to be explicit.

    As a side, You may wish to have a look at a visual studio plug-in called Code Style Enforcer (http://joel.fjorden.se/static.php?page=CodeStyleEnforcer) which uses the dxCore extensions to provide real-time feedback on your codes adherence to coding standards (fully customisable).

提交回复
热议问题