CodeClass2.Namespace Özellik

Tanım

CodeNamespaceSınıfın üst ad alanını tanımlayan bir nesne alır.

public:
 property EnvDTE::CodeNamespace ^ Namespace { EnvDTE::CodeNamespace ^ get(); };
public:
 property EnvDTE::CodeNamespace ^ Namespace { EnvDTE::CodeNamespace ^ get(); };
[System.Runtime.InteropServices.DispId(32)]
public EnvDTE.CodeNamespace Namespace { [System.Runtime.InteropServices.DispId(32)] [System.Runtime.InteropServices.TypeLibFunc(1024)] get; }
[<System.Runtime.InteropServices.DispId(32)>]
[<get: System.Runtime.InteropServices.DispId(32)>]
[<get: System.Runtime.InteropServices.TypeLibFunc(1024)>]
member this.Namespace : EnvDTE.CodeNamespace
Public ReadOnly Property Namespace As CodeNamespace

Özellik Değeri

CodeNamespace

Bir CodeNamespace nesnesi.

Uygulamalar

Öznitelikler

Örnekler

[Visual Basic]

Sub NamespaceExample(ByVal dte As DTE2)  
    ' Before running this example, open a code document from a project  
    ' and place the insertion point inside a class definition.  
    Try  
        ' Retrieve the CodeClass at the insertion point.  
        Dim sel As TextSelection = _  
            CType(dte.ActiveDocument.Selection, TextSelection)  
        Dim cls As CodeClass = _  
            CType(sel.ActivePoint.CodeElement( _  
            vsCMElement.vsCMElementClass), CodeClass)  

        If IsNothing(cls.Namespace) = False Then  
            MsgBox(cls.Name & " belongs to the " & _  
                cls.Namespace.Name & " namespace.")  
        Else  
            MsgBox(cls.Name & " doesn't belong to a namespace.")  
        End If  
    Catch ex As Exception  
        MsgBox(ex.Message)  
    End Try  
End Sub  

Þ

 public void NamespaceExample(DTE2 dte)  
{  
    // Before running this example, open a code document from a project  
    // and place the insertion point inside a class definition.  
    try  
    {  
        // Retrieve the CodeClass at the insertion point.  
        TextSelection sel =   
            (TextSelection)dte.ActiveDocument.Selection;  
        CodeClass cls =   
            (CodeClass)sel.ActivePoint.get_CodeElement(  
            vsCMElement.vsCMElementClass);  

        if (cls.Namespace != null)  
            MessageBox.Show(cls.Name + " belongs to the " +   
                cls.Namespace.Name + " namespace.");  
        else  
            MessageBox.Show(cls.Name +   
                " doesn't belong to a namespace.");  
    }  
    catch (Exception ex)  
    {  
        MessageBox.Show(ex.Message);  
    }  
}  

Açıklamalar

Bir Namespace özellik Nothing null , bir dosyanın en üst düzeyinde belirtilen türler için veya döndürür. Varsayılan bir ad alanı veya genel ad alanı için.

Not

Sınıfların, yapıların, işlevlerin, özniteliklerin, temsilcilerin ve bu gibi kod modeli öğelerinin değerleri, belirli tür düzenlemeler yapıldıktan sonra belirleyici olmayan bir değer olabilir, yani değerlerinin her zaman aynı kalır. Daha fazla bilgi için bkz. kod modeli öğe değerleri, kod modeli kullanılarak kod bulma bölümünde değişebilir (Visual Basic).

Şunlara uygulanır