Share via


HideModuleNameAttribute 類別

更新:2007 年 11 月

HideModuleNameAttribute 屬性 (Attribute) 在套用到模組時,允許只使用模組所需的限定性條件存取模組成員。

' Usage
<HideModuleName> Module moduleName
' Declaration
<System.AttributeUsage(System.AttributeTargets.Class, _
   Inherited := False, AllowMultiple := False)> _
Public NotInheritable Class HideModuleNameAttribute
   Inherits System.Attribute

備註

這個屬性有助於公開 (Expose) 模組成員,但不會顯示模組本身。在 Visual Basic 的 Visual Studio 整合式開發環境 (IDE) 中使用 IntelliSense 時,模組不會顯示在陳述式完成清單中。IntelliSense 反而會顯示模組成員。

即使模組名稱已隱藏,仍可以透過模組存取模組成員。

如果成員名稱與另一個識別項或與另一個模組 (具有 HideModuleNameAttribute 屬性) 的成員發生衝突,則成員不會顯示在模組層級的 IntelliSense 中。

範例

這個範例顯示如何使用 HideModuleNameAttribute 屬性,將資料庫物件加入至可以透過 My.Database 存取的 My。

Namespace My
    <HideModuleName()> Module CustomMyDatabase
        Public ReadOnly Property Database() As MyDatabase
            Get
                Return databaseValue
            End Get
        End Property
        Private ReadOnly databaseValue As MyDatabase = New MyDatabase
    End Module
End Namespace

Class MyDatabase
    ' The members of the My.Database object go here.
End Class

Namespace 陳述式必須出現在任何類別或模組之外。

需求

命名空間Microsoft.VisualBasic

類別HideModuleNameAttribute

**組件:**Visual Basic Runtime Library (在 Microsoft.VisualBasic.dll 中)

請參閱

概念

Visual Basic 所用的屬性

參考

VBFixedArrayAttribute 類別

VBFixedStringAttribute 類別

其他資源

Visual Basic 中的屬性