CodeVariableDeclarationStatement Klasa

Definicja

Reprezentuje deklarację zmiennej.

public ref class CodeVariableDeclarationStatement : System::CodeDom::CodeStatement
public class CodeVariableDeclarationStatement : System.CodeDom.CodeStatement
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodeVariableDeclarationStatement : System.CodeDom.CodeStatement
type CodeVariableDeclarationStatement = class
    inherit CodeStatement
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type CodeVariableDeclarationStatement = class
    inherit CodeStatement
Public Class CodeVariableDeclarationStatement
Inherits CodeStatement
Dziedziczenie
CodeVariableDeclarationStatement
Atrybuty

Przykłady

W tym przykładzie pokazano użycie elementu do CodeVariableDeclarationStatement zadeklarowania zmiennej.

// 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.
    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";
 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"

Uwagi

CodeVariableDeclarationStatement może służyć do reprezentowania kodu, który deklaruje zmienną.

Właściwość Type określa typ zmiennej do zadeklarowania. Właściwość Name określa nazwę zmiennej do zadeklarowania. Właściwość jest opcjonalna InitExpression i określa wyrażenie inicjowania, które ma zostać przypisane do zmiennej po jej utworzeniu.

Uwaga

Niektóre języki mogą implementować opcjonalne wyrażenie inicjowania zmiennej przez utworzenie oddzielnej instrukcji przypisania po deklaracji zmiennej.

Konstruktory

CodeVariableDeclarationStatement()

Inicjuje nowe wystąpienie klasy CodeVariableDeclarationStatement.

CodeVariableDeclarationStatement(CodeTypeReference, String)

Inicjuje CodeVariableDeclarationStatement nowe wystąpienie klasy przy użyciu określonego typu i nazwy.

CodeVariableDeclarationStatement(CodeTypeReference, String, CodeExpression)

Inicjuje CodeVariableDeclarationStatement nowe wystąpienie klasy przy użyciu określonego typu danych, nazwy zmiennej i wyrażenia inicjowania.

CodeVariableDeclarationStatement(String, String)

Inicjuje CodeVariableDeclarationStatement nowe wystąpienie klasy przy użyciu określonej nazwy typu danych i nazwy zmiennej.

CodeVariableDeclarationStatement(String, String, CodeExpression)

Inicjuje CodeVariableDeclarationStatement nowe wystąpienie klasy przy użyciu określonego typu danych, nazwy zmiennej i wyrażenia inicjowania.

CodeVariableDeclarationStatement(Type, String)

Inicjuje CodeVariableDeclarationStatement nowe wystąpienie klasy przy użyciu określonego typu danych i nazwy zmiennej.

CodeVariableDeclarationStatement(Type, String, CodeExpression)

Inicjuje CodeVariableDeclarationStatement nowe wystąpienie klasy przy użyciu określonego typu danych, nazwy zmiennej i wyrażenia inicjowania.

Właściwości

EndDirectives

CodeDirectiveCollection Pobiera obiekt zawierający dyrektywy końcowe.

(Odziedziczone po CodeStatement)
InitExpression

Pobiera lub ustawia wyrażenie inicjowania dla zmiennej.

LinePragma

Pobiera lub ustawia wiersz, w którym występuje instrukcja kodu.

(Odziedziczone po CodeStatement)
Name

Pobiera lub ustawia nazwę zmiennej.

StartDirectives

CodeDirectiveCollection Pobiera obiekt zawierający dyrektywy startowe.

(Odziedziczone po CodeStatement)
Type

Pobiera lub ustawia typ danych zmiennej.

UserData

Pobiera dane zdefiniowane przez użytkownika dla bieżącego obiektu.

(Odziedziczone po CodeObject)

Metody

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Dotyczy