I have the below type defined in one assembly.
public class TestAccessSpecifiers
{
public int Public { get; set; }
protected int Protected { get; set; }
private int Private { get; set; }
public void SetValues()
{
Public = 10;
Protected = 20;
Private = 30;
}
}
public class NewDerived : TestAccessSpecifiers
{
public void SetProtected()
{
Protected = 199;
}
}
In another type i am consuming this type and irrespective of whether I give protected or protected internal for the Protected Property, I am able to access it from this other program. Then what is the difference between setting both.
class Program
{
static void Main(string[] args)
{
TestAccessSpecifiers obj = new TestAccessSpecifiers();
obj.SetValues();
obj.Public = 100;
Console.WriteLine(Convert.ToString(obj.Public));
Console.ReadLine();
}
}
class Derived : TestAccessSpecifiers
{
public void SetNewValues()
{
Public = 200;
Protected = 500;
}
}