CodeAssignStatement 类

定义

表示简单的赋值语句。Represents a simple assignment statement.

public ref class CodeAssignStatement : System::CodeDom::CodeStatement
[System.Runtime.InteropServices.ComVisible(true)]
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Serializable]
public class CodeAssignStatement : System.CodeDom.CodeStatement
type CodeAssignStatement = class
    inherit CodeStatement
Public Class CodeAssignStatement
Inherits CodeStatement
继承
CodeAssignStatement
属性

示例

下面的代码创建一个CodeAssignStatement , 它将值10分配给一个名i为的整数变量:The following code creates a CodeAssignStatement that assigns the value 10 to an integer variable named i :

// Assigns the value of the 10 to the integer variable "i".
CodeAssignStatement^ as1 = gcnew CodeAssignStatement( gcnew CodeVariableReferenceExpression( "i" ),gcnew CodePrimitiveExpression( 10 ) );

// A C# code generator produces the following source code for the preceeding example code:
// i=10;
// Assigns the value of the 10 to the integer variable "i".
CodeAssignStatement as1 = new CodeAssignStatement(new CodeVariableReferenceExpression("i"), new CodePrimitiveExpression(10));

// A C# code generator produces the following source code for the preceeding example code:

// i=10;
' Assigns the value 10 to the integer variable "i".
Dim as1 As New CodeAssignStatement(New CodeVariableReferenceExpression("i"), New CodePrimitiveExpression(10))

' A Visual Basic code generator produces the following source code for the preceeding example code:

' i = 10

注解

CodeAssignStatement可用于表示一个语句, 该语句将对象的值分配给另一个对象, 或引用另一个引用。CodeAssignStatement can be used to represent a statement that assigns the value of an object to another object, or a reference to another reference. 简单赋值语句的格式通常value1为 " = value2 ", 其中value1是要赋给和value2的对象。Simple assignment statements are usually of the form " value1 = value2 ", where value1 is the object being assigned to, and value2 is being assigned. Left属性指示要分配给的对象。The Left property indicates the object to assign to. Right属性指示要分配的对象。The Right property indicates the object to assign.

构造函数

CodeAssignStatement()

初始化 CodeAssignStatement 类的新实例。Initializes a new instance of the CodeAssignStatement class.

CodeAssignStatement(CodeExpression, CodeExpression)

使用指定的表达式初始化 CodeAssignStatement 类的新实例。Initializes a new instance of the CodeAssignStatement class using the specified expressions.

属性

EndDirectives

获取包含结束指令的 CodeDirectiveCollection 对象。Gets a CodeDirectiveCollection object that contains end directives.

(继承自 CodeStatement)
Left

获取或设置表示要对其赋值的对象或引用的表达式。Gets or sets the expression representing the object or reference to assign to.

LinePragma

获取或设置代码语句所在的行。Gets or sets the line on which the code statement occurs.

(继承自 CodeStatement)
Right

获取或设置表示要赋予的对象或引用的表达式。Gets or sets the expression representing the object or reference to assign.

StartDirectives

获取包含开始指令的 CodeDirectiveCollection 对象。Gets a CodeDirectiveCollection object that contains start directives.

(继承自 CodeStatement)
UserData

获取当前对象的用户可定义数据。Gets the user-definable data for the current object.

(继承自 CodeObject)

方法

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

适用于