CodeExpressionStatement 类
定义
表示由单个表达式组成的语句。Represents a statement that consists of a single expression.
public ref class CodeExpressionStatement : System::CodeDom::CodeStatement
public class CodeExpressionStatement : System.CodeDom.CodeStatement
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodeExpressionStatement : System.CodeDom.CodeStatement
type CodeExpressionStatement = class
inherit CodeStatement
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type CodeExpressionStatement = class
inherit CodeStatement
Public Class CodeExpressionStatement
Inherits CodeStatement
- 继承
- 属性
示例
下面的示例演示如何使用对象创建类的实例 CodeExpressionStatement CodeExpression 。The following example demonstrates how to create an instance of the CodeExpressionStatement class by using a CodeExpression object.
// Creates a code expression for a CodeExpressionStatement to contain.
array<CodeExpression^>^ temp = {gcnew CodePrimitiveExpression( "Example string" )};
CodeExpression^ invokeExpression = gcnew CodeMethodInvokeExpression(
gcnew CodeTypeReferenceExpression( "Console" ),"Write",temp );
// Creates a statement using a code expression.
CodeExpressionStatement^ expressionStatement;
expressionStatement = gcnew CodeExpressionStatement( invokeExpression );
// A C++ code generator produces the following source code for the preceeding example code:
// Console::Write( "Example string" );
// Creates a code expression for a CodeExpressionStatement to contain.
CodeExpression invokeExpression = new CodeMethodInvokeExpression(
new CodeTypeReferenceExpression("Console"),
"Write", new CodePrimitiveExpression("Example string") );
// Creates a statement using a code expression.
CodeExpressionStatement expressionStatement;
expressionStatement = new CodeExpressionStatement( invokeExpression );
// A C# code generator produces the following source code for the preceeding example code:
// Console.Write( "Example string" );
' Creates a code expression for a CodeExpressionStatement to contain.
Dim invokeExpression = New CodeMethodInvokeExpression( _
New CodeTypeReferenceExpression("Console"), "Write", _
New CodePrimitiveExpression("Example string"))
' Creates a statement using a code expression.
Dim expressionStatement As CodeExpressionStatement
expressionStatement = New CodeExpressionStatement(invokeExpression)
' A C# code generator produces the following source code for the preceeding example code:
' Console.Write( "Example string" );
注解
CodeExpressionStatement包含一个 CodeExpression 对象,可将其添加到 CodeStatementCollection 对象中,从而使某些表达式独立。A CodeExpressionStatement contains a CodeExpression object, and it can be added to a CodeStatementCollection object, allowing some expressions to stand alone. 例如,包含的 CodeMethodInvokeExpression CodeExpressionStatement 可以表示不带返回值的方法调用。For example, a CodeMethodInvokeExpression contained by a CodeExpressionStatement can represent a method call without a return value.
构造函数
| CodeExpressionStatement() |
初始化 CodeExpressionStatement 类的新实例。Initializes a new instance of the CodeExpressionStatement class. |
| CodeExpressionStatement(CodeExpression) |
使用指定的表达式初始化 CodeExpressionStatement 类的新实例。Initializes a new instance of the CodeExpressionStatement class by using the specified expression. |
属性
| EndDirectives |
获取包含结束指令的 CodeDirectiveCollection 对象。Gets a CodeDirectiveCollection object that contains end directives. (继承自 CodeStatement) |
| Expression |
获取或设置语句的表达式。Gets or sets the expression for the statement. |
| LinePragma |
获取或设置代码语句所在的行。Gets or sets the line on which the code statement occurs. (继承自 CodeStatement) |
| 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() |
获取当前实例的 Type。Gets 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) |