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

前端 未结 10 1800
星月不相逢
星月不相逢 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:27

    Yes they are equal but I like to mark private variables as private, I think it improves reading.

    also I use this common notation for private members, it's very useful :

    private string _bar;
    

提交回复
热议问题