什么是受保护的内部意味着净 [英] What does Protected Internal mean in .Net
问题描述
受保护的方法,就可以访问这个成员只在派生类,和内部的手段,我们可以用一个对象访问该成员在任何类型的同一程序。 因此,我可以考虑的受保护的内部成员作为在同一组件的公共成员。,并在不同的组件中的保护成员
Protected Means, we can access this member only in a deriving class, and internal means we can access this member in any type in the same assembly using a object. So can I consider a Protected Internal member as a public member in the same assembly. and as a protected member in the different assembly.
编辑:
namespace pracConsole
{
class Class1
{
protected internal int val;
public int hello()
{
Console.WriteLine("This is method pracConsole.hello");
Console.ReadLine();
return 1;
}
}
class program
{
static void Main(string[] args)
{
Class1 _class1 = new Class1();
_class1.val = 3;
_class1.hello();
Console.ReadLine();
}
}
}
请参阅我能够访问,在非派生类保护的内部...所以它作为公开工作在同一个assembly..what你说了。
See I am able to access, protected internal in a non deriving class...so its working as public in same assembly..what do you say.
推荐答案
这是一个令人困惑的。
保护的意思是只有这个类和派生类。
protected means "only this class and derived classes".
内部的意思是只有类在本次大会。
internal means "only classes in this assembly".
受保护的内部办法的保护或内部(任何类在同一个程序集,或的任何派生类 - 的即使它是在一个不同的装配的)。
protected internal means "protected OR internal" (any class in the same assembly, or any derived class - even if it is in a different assembly).
即。它的不可以的意思是保护和内部(同一个组件内只有派生类)。
i.e. it does not mean "protected AND internal" (only derived classes within the same assembly).
这篇关于什么是受保护的内部意味着净的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!