Export (0) Print
Expand All

CodeExpressionStatement Class

Represents a statement that consists of a single expression.

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

Namespace:  System.CodeDom
Assembly:  System (in System.dll)

[SerializableAttribute]
[ComVisibleAttribute(true)]
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
public class CodeExpressionStatement : CodeStatement

The CodeExpressionStatement type exposes the following members.

  NameDescription
Public methodCodeExpressionStatement()Initializes a new instance of the CodeExpressionStatement class.
Public methodCodeExpressionStatement(CodeExpression)Initializes a new instance of the CodeExpressionStatement class by using the specified expression.
Top

  NameDescription
Public propertyEndDirectivesGets a CodeDirectiveCollection object that contains end directives. (Inherited from CodeStatement.)
Public propertyExpressionGets or sets the expression for the statement.
Public propertyLinePragmaGets or sets the line on which the code statement occurs. (Inherited from CodeStatement.)
Public propertyStartDirectivesGets a CodeDirectiveCollection object that contains start directives. (Inherited from CodeStatement.)
Public propertyUserDataGets the user-definable data for the current object. (Inherited from CodeObject.)
Top

  NameDescription
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

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

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


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

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

Community Additions

ADD
Show:
© 2014 Microsoft