CodeVariable2.IsConstant Özellik

Tanım

Öğenin sabit olup olmadığını gösteren bir değer alır veya ayarlar.

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

Özellik Değeri

Boolean

Öğe bir sabit ise bir Boole değeri true ; Aksi durumda, false .

Uygulamalar

Öznitelikler

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

Açıklamalar

IsConstant Bu kod değişkeni tarafından temsil edilen depolama konumunun ayarlanabilir olup olmadığını döndürür.

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