CodeVariable2.IsConstant – vlastnost
Získá nebo nastaví hodnotu označující, zda zboží je konstanta.
Obor názvů: EnvDTE80
Sestavení: EnvDTE80 (v EnvDTE80.dll)
Syntaxe
'Deklarace
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)
Hodnota vlastnosti
Typ: System.Boolean
Logická hodnota, která je true Pokud je položka konstanta; jinak false.
Implementuje
Poznámky
IsConstantVrátí zda reprezentované tuto proměnnou kód umístění úložiště je nastavitelná.
Poznámka
Deterministický může být po provedení určité typy úprav, což znamená, že jejich hodnoty nelze dovolávat vždy zůstat stejné hodnoty prvků modelu kód jako třídy, struktury, funkce, atributy, delegátů a tak dále. Další informace naleznete v části Změna hodnoty prvku modelu kódu Discovering Code by Using the Code Model (Visual Basic).
Příklady
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);
}
}
Zabezpečení rozhraní .NET Framework
- Plná důvěra přímému volajícímu. Částečně zabezpečený kód nemůže tento člen použít. Další informace naleznete v tématu Používání knihoven z částečně důvěryhodného kódu.
Viz také
Odkaz
Další zdroje
How to: Compile and Run the Automation Object Model Code Examples