System.CodeDom.CodeVariableDeclarationStatement Class

Assembly: System.dll
Namespace: System.CodeDom
Summary
Represents a declaration of a variable.
C# Syntax:
[Serializable]
public class CodeVariableDeclarationStatement : CodeStatement
Remarks
CodeVariableDeclarationStatement can be used to represent code that declares a variable.

Note Some languages can implement the optional variable initialization expression by making a separate assignment statement after the variable declaration.
See also:
System.CodeDom Namespace

System.CodeDom.CodeVariableDeclarationStatement Member List:

Public Constructors
ctor #1 Overloaded:
.ctor()

Default constructor. This constructor is called by derived class constructors to initialize state in this type.
Initializes a new instance of the CodeVariableDeclarationStatement class.
ctor #2 Overloaded:
.ctor(CodeTypeReference type, string name)

Initializes a new instance of the CodeVariableDeclarationStatement class using the specified type and name.
ctor #3 Overloaded:
.ctor(string type, string name)

Initializes a new instance of the CodeVariableDeclarationStatement class using the specified data type name and variable name.
ctor #4 Overloaded:
.ctor(Type type, string name)

Initializes a new instance of the CodeVariableDeclarationStatement class using the specified data type and variable name.
ctor #5 Overloaded:
.ctor(CodeTypeReference type, string name, CodeExpression initExpression)

Initializes a new instance of the CodeVariableDeclarationStatement class using the specified data type, variable name, and initialization expression.
ctor #6 Overloaded:
.ctor(string type, string name, CodeExpression initExpression)

Initializes a new instance of the CodeVariableDeclarationStatement class using the specified data type, variable name, and initialization expression.
ctor #7 Overloaded:
.ctor(Type type, string name, CodeExpression initExpression)

Initializes a new instance of the CodeVariableDeclarationStatement class using the specified data type, variable name, and initialization expression.
Public Properties
InitExpression Read-write

Gets or sets the initialization expression for the variable.
LinePragma
(inherited from System.CodeDom.CodeStatement)
Read-write

See base class member description: System.CodeDom.CodeStatement.LinePragma


Gets or sets the line the statement occurs on.
Name Read-write

Gets or sets the name of the variable.
Type Read-write

Gets or sets the type of the variable.
UserData
(inherited from System.CodeDom.CodeObject)
Read-only

See base class member description: System.CodeDom.CodeObject.UserData


Gets or sets the user-definable data for the current object.
Public Methods
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
GetHashCode
(inherited from System.Object)
See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
Protected Methods
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.

Hierarchy:


System.CodeDom.CodeVariableDeclarationStatement Member Details

Overloaded ctor #1
Summary
Initializes a new instance of the CodeVariableDeclarationStatement class.

Default constructor. This constructor is called by derived class constructors to initialize state in this type.
C# Syntax:
public CodeVariableDeclarationStatement();

Return to top


Overloaded ctor #2
Summary
Initializes a new instance of the CodeVariableDeclarationStatement class using the specified type and name.
C# Syntax:
public CodeVariableDeclarationStatement(
   CodeTypeReference type,
   string name
);
Parameters:

type

A CodeTypeReference that indicates the type of the variable.

name

The name of the variable.

Return to top


Overloaded ctor #3
Summary
Initializes a new instance of the CodeVariableDeclarationStatement class using the specified data type name and variable name.
C# Syntax:
public CodeVariableDeclarationStatement(
   string type,
   string name
);
Parameters:

type

The name of the data type of the variable.

name

The name of the variable.

Return to top


Overloaded ctor #4
Summary
Initializes a new instance of the CodeVariableDeclarationStatement class using the specified data type and variable name.
C# Syntax:
public CodeVariableDeclarationStatement(
   Type type,
   string name
);
Parameters:

type

The data type for the variable.

name

The name of the variable.

Return to top


Overloaded ctor #5
Summary
Initializes a new instance of the CodeVariableDeclarationStatement class using the specified data type, variable name, and initialization expression.
C# Syntax:
public CodeVariableDeclarationStatement(
   CodeTypeReference type,
   string name,
   CodeExpression initExpression
);
Parameters:

type

A CodeTypeReference that indicates the type of the variable.

name

The name of the variable.

initExpression

A CodeExpression that indicates the initialization expression for the variable.

See also:
CodeExpression

Return to top


Overloaded ctor #6
Summary
Initializes a new instance of the CodeVariableDeclarationStatement class using the specified data type, variable name, and initialization expression.
C# Syntax:
public CodeVariableDeclarationStatement(
   string type,
   string name,
   CodeExpression initExpression
);
Parameters:

type

The name of the data type of the variable.

name

The name of the variable.

initExpression

A CodeExpression that indicates the initialization expression for the variable.

Return to top


Overloaded ctor #7
Summary
Initializes a new instance of the CodeVariableDeclarationStatement class using the specified data type, variable name, and initialization expression.
C# Syntax:
public CodeVariableDeclarationStatement(
   Type type,
   string name,
   CodeExpression initExpression
);
Parameters:

type

The data type of the variable.

name

The name of the variable.

initExpression

A CodeExpression that indicates the initialization expression for the variable.

Return to top


Property: InitExpression (read-write)
Summary
Gets or sets the initialization expression for the variable.
C# Syntax:
public CodeExpression InitExpression {get; set;}
See also:
CodeExpression

Return to top


Property: LinePragma (read-write)
Inherited
See base class member description: System.CodeDom.CodeStatement.LinePragma

Summary
Gets or sets the line the statement occurs on.
C# Syntax:
public CodeLinePragma LinePragma {get; set;}
Remarks
This property indicates the location of the statement.
See also:
CodeLinePragma

Return to top


Property: Name (read-write)
Summary
Gets or sets the name of the variable.
C# Syntax:
public string Name {get; set;}

Return to top


Property: Type (read-write)
Summary
Gets or sets the type of the variable.
C# Syntax:
public CodeTypeReference Type {get; set;}

Return to top


Property: UserData (read-only)
Inherited
See base class member description: System.CodeDom.CodeObject.UserData

Summary
Gets or sets the user-definable data for the current object.
C# Syntax:
public IDictionary UserData {get;}
Remarks


Notes to inheritors: An inheritor can design the way this user data is stored, retrieved, and used.

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~CodeVariableDeclarationStatement();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.