方法,无需访问修饰符方法、修饰符

2023-09-03 00:19:50 作者:待我发光闪瞎你

确定这是窃听我..我知道我在什么地方读它和谷歌是没有帮助的。

Ok this is bugging me.. I know I've read it somewhere and google isn't helping.

什么是方法的访问级别,不指定一个访问修饰符?

What is the accessibility level of a method that does not specify an access modifier?

void Foo()
{
    //code
} 

我想说内部,但我不是100%肯定。

I want to say internal but I'm not 100% sure.

推荐答案

默认的辅助功能的键入是内部,但默认accesibility该类型的成员取决于类型。

The default accessibility for a type is internal, but the default accesibility of that type's members depends on the type.

一般而言,类的成员是私人默认情况下,在这里作为一个结构的成员公开默认情况下。这会因语言;默认结构的C ++是公开的,在这里为C#,他们是私人的访问修饰符。

Generally speaking, members of a class are private by default, where as members of a struct are public by default. This varies by language; default struct access modifiers for C++ are public, where as for C#, they are private.