Why explicitly write “private”?

前端 未结 8 1743
孤城傲影
孤城傲影 2020-12-17 08:46

As fields are implicitly private, why there is often explicit declaraion used in the books, articles etc.?

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-17 09:09

    Sometimes explicit is better than implicit, and this is even more so when you are writing educational material. For people who do not know or cannot remember the rules for the default access levels it is one less thing for them to be concerned with when reading the code.

    Related Question

    • What are the Default Access Modifiers in C#?

    The default access for everything in C# is "the most restricted access you could declare for that member".

提交回复
热议问题