这就是一些关于安全性的问题拉:
public class A
{
private string name;
public int ID; public void GetName()
{} internal void GetID()
{} private void GetPassword()
{} }
public class B:A
{
}
在Class B中Class A中的字段name,方法GetPassword()是不能被访问的拉。。
public class A
{
private string name;
public int ID; public void GetName()
{} internal void GetID()
{} private void GetPassword()
{} }
public class B:A
{
}
在Class B中Class A中的字段name,方法GetPassword()是不能被访问的拉。。
{
private void PrivateMethod() {} protected void ProtectedMethod() {} public void PublicMethod() {}
}public class Child : Parent
{
public void ChildMethod()
{
PublicMethod(); //可以调用
ProtectedMethod(); //可以调用
PrivateMethod(); //不能调用,因为这是父类的私有方法
}
}在某个地方使用Child类:
Child cld = new Child();
cld.PrivateMethod(); //不能调用
cld.ProtectedMethod(); //在外部不能调用,只能在类的内部调用
cld.PublicMethod(); //可以调用