Udostępnij za pośrednictwem


Właściwość CodeVariable2.IsConstant —

Pobiera lub ustawia wartość wskazującą, czy element jest stała.

Przestrzeń nazw:  EnvDTE80
Zestaw:  EnvDTE80 (w EnvDTE80.dll)

Składnia

'Deklaracja
Property IsConstant As Boolean
bool IsConstant { get; set; }
property bool IsConstant {
    bool get ();
    void set (bool value);
}
abstract IsConstant : bool with get, set
function get IsConstant () : boolean 
function set IsConstant (value : boolean)

Wartość właściwości

Typ: Boolean
Wartość logiczna, która jest true Jeśli element jest stała; w przeciwnym razie false.

Uwagi

IsConstantZwraca do ustawienia jest reprezentowany przez zmienną ten kod lokalizacji magazynu czy też nie.

[!UWAGA]

Wartości elementów modelu kodu, takich jak klasy, strukturach, funkcje, atrybuty, delegatów i tak dalej mogą być deterministyczny po dokonaniu niektórych rodzajów modyfikacji, co oznacza, że ich wartości nie mogą być powoływane do zawsze pozostają takie same.Aby uzyskać więcej informacji, zobacz sekcję wartości elementu modelu kod można zmienić w Odnajdowanie kodu za pomocą modelu kodu (Visual Basic).

Przykłady

Sub IsConstantExample(ByVal dte As DTE2)

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

        ' Display whether the variable is constant.
        If var.IsConstant Then
            MsgBox(var.Name & " is a constant.")
        Else
            MsgBox(var.Name & " is not a constant.")
        End If
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try

End Sub
public void IsConstantExample(DTE2 dte)
{
    // Before running this example, open a code document from a project
    // and place the insertion point inside a variable definition.
    try
    {
        // Retrieve the CodeVariable at the insertion point.
        TextSelection sel = 
            (TextSelection)dte.ActiveDocument.Selection;
        CodeVariable var = 
            (CodeVariable)sel.ActivePoint.get_CodeElement(
            vsCMElement.vsCMElementVariable);

        // Display whether the variable is constant.
        if (var.IsConstant)
            MessageBox.Show(var.Name + " is a constant.");
        else
            MessageBox.Show(var.Name + " is not a constant.");
            }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

Zabezpieczenia programu .NET Framework

Zobacz też

Informacje

CodeVariable2 Interfejs

Przestrzeń nazw EnvDTE80

Inne zasoby

Porady: kompilowanie i uruchamianie kodu modelu obiektów automatyzacji — przykłady

Odnajdowanie kodu za pomocą modelu kodu (Visual Basic)

Odnajdowanie kodu za pomocą modelu kodu (Visual C#)