Aracılığıyla paylaş


CodeVariable2.IsConstant Özellik

Alır veya öğeyi bir sabit olup olmadığını gösteren bir değeri ayarlar.

Ad alanı:  EnvDTE80
Derleme:  EnvDTE80 (EnvDTE80.dll içinde)

Sözdizimi

'Bildirim
Property IsConstant As Boolean
    Get
    Set
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)

Özellik Değeri

Tür: System.Boolean
Olan bir Boole değeri true , madde, sabit; Aksi takdirde, false.

Yüklenen

CodeVariable.IsConstant

Açıklamalar

IsConstantBu kod değişkeniyle temsil edilen depolama konumu ayarlanabilir olup olmadığını döndürür.

Not

Sınıflar, yapılar, işlevleri, öznitelikleri, Temsilciler ve benzeri gibi kod modeli öğeleri değerlerini düzenlemeleri değerlerine bağlı her zaman aynı kalmasını dayanıyordu olamaz, diğer bir deyişle, belirli türde yaptıktan sonra non-deterministik olabilir. Daha fazla bilgi için bkz: kod modeli öğe değerlerini de değiştirebilirsiniz bölüm Kod modeli (@) kullanarak kodu keşfetme.

Örnekler

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);
    }
}

.NET Framework Güvenliği

Ayrıca bkz.

Başvuru

CodeVariable2 Arabirim

IsConstant Fazla Yük

EnvDTE80 Ad Alanı

Diğer Kaynaklar

Nasıl Yapılır: derlemek ve otomasyon nesne modeli kod örnekleri çalıştırma

Kod modeli (@) kullanarak kodu keşfetme

Kod modeli (Visual C#) kullanarak kodu keşfetme