Export (0) Print
Expand All

CodeExpressionStatement Class

Represents a statement that consists of a single expression.

For a list of all members of this type, see CodeExpressionStatement Members.

System.Object
   System.CodeDom.CodeObject
      System.CodeDom.CodeStatement
         System.CodeDom.CodeExpressionStatement

[Visual Basic]
<Serializable>
<ClassInterface(ClassInterfaceType.AutoDispatch)>
<ComVisible(True)>
Public Class CodeExpressionStatement
   Inherits CodeStatement
[C#]
[Serializable]
[ClassInterface(ClassInterfaceType.AutoDispatch)]
[ComVisible(true)]
public class CodeExpressionStatement : CodeStatement
[C++]
[Serializable]
[ClassInterface(ClassInterfaceType::AutoDispatch)]
[ComVisible(true)]
public __gc class CodeExpressionStatement : public CodeStatement
[JScript]
public
   Serializable
 ClassInterface(ClassInterfaceType.AutoDispatch)
 ComVisible(true)
class CodeExpressionStatement extends CodeStatement

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Remarks

CodeExpressionStatement can represent a statement that consists of a single expression.

A CodeExpressionStatement contains a CodeExpression, and it can be added to a CodeStatementCollection, allowing some expressions to stand alone. For example, a CodeMethodInvokeExpression contained by a CodeExpressionStatement can represent a method call without a return value.

Example

[Visual Basic] 
' 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" );

[C#] 
// 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" );

[C++] 
// Creates a code expression for a CodeExpressionStatement to contain.
CodeExpression* temp[] = {new CodePrimitiveExpression(S"Example string")};
CodeExpression* invokeExpression = new CodeMethodInvokeExpression( 
    new CodeTypeReferenceExpression(S"Console"), 
    S"Write",
    temp);

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

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.CodeDom

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System (in System.dll)

See Also

CodeExpressionStatement Members | System.CodeDom Namespace

Show:
© 2014 Microsoft