CodeFunction.IsShared Eigenschaft

Definition

Legt fest oder Ruft ab, ob das Element statisch definiert ist, d. h. ob das Element für alle Instanzen dieses Objekt Typs oder nur für dieses Objekt gilt.

public:
 property bool IsShared { bool get(); void set(bool value); };
public:
 property bool IsShared { bool get(); void set(bool value); };
[System.Runtime.InteropServices.DispId(40)]
public bool IsShared { [System.Runtime.InteropServices.DispId(40)] get; [System.Runtime.InteropServices.DispId(40)] set; }
[<System.Runtime.InteropServices.DispId(40)>]
[<get: System.Runtime.InteropServices.DispId(40)>]
[<set: System.Runtime.InteropServices.DispId(40)>]
member this.IsShared : bool with get, set
Public Property IsShared As Boolean

Eigenschaftswert

Boolean

Ein boolescher Wert true , der angibt, ob die Methode freigegeben ist; false andernfalls.

Attribute

Beispiele

 Sub IsSharedExample(ByVal dte As DTE2)  

    ' Before running this example, open a code document from a project  
    ' and place the insertion point inside a function.  
    Try  
        ' Retrieve the CodeFunction at the insertion point.  
        Dim sel As TextSelection = _  
            CType(dte.ActiveDocument.Selection, TextSelection)  
        Dim fun As CodeFunction = _  
            CType(sel.ActivePoint.CodeElement( _  
            vsCMElement.vsCMElementFunction), CodeFunction)  

        If fun.IsShared Then  
            MsgBox(fun.Name & " is an instance method.")  
        Else  
            MsgBox(fun.Name & " is not an instance method.")  
        End If  
    Catch ex As Exception  
        MsgBox(ex.Message)  
    End Try  

End Sub  
 public void IsSharedExample(DTE2 dte)  
{  
    // Before running this example, open a code document from a project  
    // and place the insertion point inside a function.  
    try  
    {  
        // Retrieve the CodeFunction at the insertion point.  
        TextSelection sel =   
            (TextSelection)dte.ActiveDocument.Selection;  
        CodeFunction fun =   
            (CodeFunction)sel.ActivePoint.get_CodeElement(  
            vsCMElement.vsCMElementFunction);  

        if (fun.IsShared)  
            MessageBox.Show(fun.Name + " is an instance method.");  
        else  
            MessageBox.Show(fun.Name + " is not an instance method.");  
    }  
    catch (Exception ex)  
    {  
        MessageBox.Show(ex.Message);  
    }  
}  

Hinweise

IsShared Gibt zurück oder legt fest, ob die Methode einer Klasse oder mit Instanzen einer Klasse zugeordnet ist. Beachten Sie, dass durch Festlegen dieses Fehlers sprachabhängige Fehler auftreten können. Obwohl IsShared erfolgreich zurückgibt, bedeutet dies nicht, dass die resultierende Codeänderung erfolgreich kompiliert wird.

Hinweis

Die Werte von Codemodellelementen wie z. B. Klassen, Strukturen, Funktionen, Attributen Delegaten usw. sind nach bestimmten Änderungen unter Umständen nicht deterministisch, d. h. deren Werte bleiben nicht zuverlässig immer gleich. Weitere Informationen finden Sie im Abschnitt Code Modell Element-Werte können sich in ermitteln von Code mithilfe des Code Modells (Visual Basic)ändern.

Gilt für