c#中的类访问修饰符

来源:互联网 发布:arp专杀软件 编辑:程序博客网 时间:2024/06/06 03:05

public ---   无新意

private  --- 无新意

protected -- 无新意

internal  -- 同一个执行文件(exe)或者类库dll中的类可访问

protected internal --  故名思意

 

C#中的类属性的get/set方法可以有单独的访问修饰符,如

public string property1{

   get {return pro1;}

   protected set {pro1 = value;}

}

实现只读

public string property1{

   get {return pro1;}

}

 

静态属性

public class staticProTest{

   public static staticVa =0;

   public static staticPro{

    get{return staticVa;}

    Set(staticVa = value;}

}

}