I am raising a question (again) on the protected
vs protected internal
as I am still unsure and not able to get a grip on them.
Any help is much appreciated.
// DLL 1
namespace Assembly1
{
class class1 : class2
{
static void Main()
{
new class1().Test();
}
private void Test()
{
Console.WriteLine(this.sample);
}
}
}
// DLL 2
namespace Assembly2
{
public class class2
{
// protected string sample = "Test";
protected internal string sample = "Test";
//Same behavior when using protected and protected internal. Why ?
}
}
I am getting the same behaviour for both the lines.
// protected string sample = "Test";
protected internal string sample = "Test";
But I am sure that there should be some difference.
MSDN says:
Protected: Access is limited to the containing class or types derived from the containing class.Protected Internal: Access is limited to the current assembly or types derived from the containing class.
I am able to access both protected
and protected internal
from outside assemblies as long as I inherit from the base class.
Pretty confusing! both looks exactly similar. Can any one explain me by modifying from the above example ?