Any reason to write the “private” keyword in C#?

后端 未结 9 583
梦谈多话
梦谈多话 2020-12-04 18:54

As far as I know, private is the default everywhere in C# (meaning that if I don\'t write public, protected, internal

9条回答
  •  青春惊慌失措
    2020-12-04 19:27

    As far as I know, private is the default everywhere in C#

    Explicitly declaring private, means you know it is private. Not just think it is, because as far as you know, it is the default. It also means that someone else who looks at the code knows what it is.

    There is no "I think it is", "I'm pretty sure it is", etc. It just is. And everyone is on the same page.

    I am not a C# developer. If I had to work with some code that wasn't explicitly declared private, I would probably assume it was internal.

    I dislike when things are implicitly set. It's never as clear as when they are explicitly set.

提交回复
热议问题