C#是否需要private关键字?
问题描述:
(灵感来自此评论)
是否曾经有一种情况,您需要使用private
关键字?
(换句话说,省略关键字会导致不同的行为)
Is there ever a situation in which you need to use the private
keyword?
(In other words, a situation in which omitting the keyword would result in different behavior)
答
public class Foo
{
public int Bar { get; private set; }
}
省略私人"一词会改变可访问性.
Omitting the word 'private' would change the accessibility.