C#的protected internal
第一種解釋是,protected or internal ,即在本程序集或其他程序集繼承的子類可以訪問。
第二種解釋是,protected and internal,即在本類或本程序集繼承的子類可以訪問。
這需要判斷protected ?internal 是何種解釋,就要從微軟的MSDN中得到答案。
摘要原文:
protected internal
The type or member can be accessed by any code in the assembly in which it is declared, or from within a derived class in another assembly. Access from another assembly must take place within a class declaration that derives from the class in which the protected internal element is declared, and it must take place through an instance of the derived class type.
譯文:
該類型或成員可以在聲明的程序集的程序集中的任何代碼或在另一個程序集內的派生類中訪問。從另一個程序集的訪問必須發生在一個類聲明中,該類聲明中聲明受保護的內部元素的類,它必須通過派生類類型的實例發生。
微軟開發者:
protected internal
由其聲明的程序集或另一個程序集派生的類中任何代碼都可訪問的類型或成員。 從另一個程序集進行訪問必須在類聲明中發生,該類聲明派生自其中聲明受保護的內部元素的類,并且必須通過派生的類類型的實例發生。
所以,protected ?internal 是在本程序集或其他程序集繼承的子類可以訪問。
?
總結
以上是生活随笔為你收集整理的C#的protected internal的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: lenovowindows7pc配置?
- 下一篇: C# WinIo获取键盘记录