CodeExpressionStatement 构造函数

定义

初始化 CodeExpressionStatement 类的新实例。

重载

CodeExpressionStatement()

初始化 CodeExpressionStatement 类的新实例。

CodeExpressionStatement(CodeExpression)

使用指定的表达式初始化 CodeExpressionStatement 类的新实例。

CodeExpressionStatement()

Source:
CodeExpressionStatement.cs
Source:
CodeExpressionStatement.cs
Source:
CodeExpressionStatement.cs

初始化 CodeExpressionStatement 类的新实例。

public:
 CodeExpressionStatement();
public CodeExpressionStatement ();
Public Sub New ()

适用于

CodeExpressionStatement(CodeExpression)

Source:
CodeExpressionStatement.cs
Source:
CodeExpressionStatement.cs
Source:
CodeExpressionStatement.cs

使用指定的表达式初始化 CodeExpressionStatement 类的新实例。

public:
 CodeExpressionStatement(System::CodeDom::CodeExpression ^ expression);
public CodeExpressionStatement (System.CodeDom.CodeExpression expression);
new System.CodeDom.CodeExpressionStatement : System.CodeDom.CodeExpression -> System.CodeDom.CodeExpressionStatement
Public Sub New (expression As CodeExpression)

参数

expression
CodeExpression

语句的 CodeExpression

示例

以下示例创建 一个 CodeExpression 对象,并将其用作参数来初始化 类的 CodeExpressionStatement 实例。

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

适用于