C#是否需要private关键字? [英] Does C# need the private keyword?
本文介绍了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.
这篇关于C#是否需要private关键字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文