有用的辦法 view object 's accessible modifier by VS ObjectBrowser


之前一直困擾於在C#中各種對象的訪問修飾符,

     默認方位修飾符是什麼?

     某種類型只能使用哪些訪問修飾符?

     等等

 

今天發現,可以用VS的Ojbect Browser來查看,再結合代碼,就便於理解了

case 1:

           the default accessiable modifer for class is internal.

          Internal means only the member in the same assembly(equal to namespace?)  or its derived memeber could use each other.

 

        

 

      the code is displayed in the following:

    

class Class1
  {
   

  }


case2: if enum is writted in a class , the default accessiable modifer for enum is private 

 

    

 

 

  public class classDong
  {
     enum MeasureTypein
    {
      rtk,
      vrs
    }
    public static string GetMeasureType(MeasureTypein type )
    {
      switch (type)
      {
        case MeasureTypein.rtk:
          return "rtk";
        case MeasureTypein.vrs:
          return "vrs";
      }

  }


 

 

 

    

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章