Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Stellt eine Variablendeklaration dar.
Namespace: System.CodeDom
Assembly: System (in system.dll)
Syntax
'Declaration
<SerializableAttribute> _
<ComVisibleAttribute(True)> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
Public Class CodeVariableDeclarationStatement
Inherits CodeStatement
'Usage
Dim instance As CodeVariableDeclarationStatement
[SerializableAttribute]
[ComVisibleAttribute(true)]
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
public class CodeVariableDeclarationStatement : CodeStatement
[SerializableAttribute]
[ComVisibleAttribute(true)]
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)]
public ref class CodeVariableDeclarationStatement : public CodeStatement
/** @attribute SerializableAttribute() */
/** @attribute ComVisibleAttribute(true) */
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */
public class CodeVariableDeclarationStatement extends CodeStatement
SerializableAttribute
ComVisibleAttribute(true)
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)
public class CodeVariableDeclarationStatement extends CodeStatement
Hinweise
Mit CodeVariableDeclarationStatement kann Code dargestellt werden, der eine Variable deklariert.
Die Type-Eigenschaft gibt den Typ der Variablen an, die deklariert werden soll. Die Name-Eigenschaft gibt den Namen der Variablen an, die deklariert werden soll. Die InitExpression-Eigenschaft ist optional und gibt einen Initialisierungsausdruck an, der der Variablen nach ihrer Erstellung zugewiesen werden soll.
Hinweis
Bei einigen Sprachen kann der optionale Initialisierungsausdruck für Variablen implementiert werden, indem auf die Variablendeklaration eine getrennte Zuweisungsanweisung folgt.
Beispiel
In diesem Beispiel wird veranschaulicht, wie mit einem CodeVariableDeclarationStatement eine Variable deklariert wird.
Dim variableDeclaration As New CodeVariableDeclarationStatement( _
GetType(String), "TestString", _
New CodePrimitiveExpression("Testing"))
' The first two parameters indicate the type and name of the variable to declare.
' The optional initExpression parameter initializes the variable.
' A Visual Basic code generator produces the following source code for the preceeding example code:
' Dim TestString As String = "Testing"
CodeVariableDeclarationStatement variableDeclaration = new CodeVariableDeclarationStatement(
// Type of the variable to declare.
typeof(string),
// Name of the variable to declare.
"TestString",
// Optional initExpression parameter initializes the variable.
new CodePrimitiveExpression("Testing") );
// A C# code generator produces the following source code for the preceeding example code:
// string TestString = "Testing";
// Type of the variable to declare.
// Name of the variable to declare.
// Optional initExpression parameter initializes the variable.
CodeVariableDeclarationStatement^ variableDeclaration = gcnew CodeVariableDeclarationStatement( String::typeid,"TestString",gcnew CodePrimitiveExpression( "Testing" ) );
// A C# code generator produces the following source code for the preceeding example code:
// string TestString = "Testing";
CodeVariableDeclarationStatement variableDeclaration =
new CodeVariableDeclarationStatement(
// Type of the variable to declare.
String.class.ToType(),
// Name of the variable to declare.
"TestString",
// Optional initExpression parameter initializes the variable.
new CodePrimitiveExpression("Testing"));
// A VJ# code generator produces the following source code for the
// preceeding example code:
// String testString = "Testing";
Vererbungshierarchie
System.Object
System.CodeDom.CodeObject
System.CodeDom.CodeStatement
System.CodeDom.CodeVariableDeclarationStatement
Threadsicherheit
Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.
Plattformen
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
CodeVariableDeclarationStatement-Member
System.CodeDom-Namespace