Export (0) Print
Expand All

CodeTypeOfExpression Class

Represents a typeof expression, an expression that returns a Type for a specified type name.

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

System.Object
   System.CodeDom.CodeObject
      System.CodeDom.CodeExpression
         System.CodeDom.CodeTypeOfExpression

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

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

A CodeTypeOfExpression represents a typeof expression that returns a Type at runtime.

The Type property specifies the data type to return a Type object for.

Use CodeTypeReferenceExpression to represent source code that refers to a type by name, such as when creating a CodeCastExpression to cast an object to a name-specified type.

Example

[Visual Basic, C#, C++] The following example demonstrates use of a CodeTypeOfExpression to represent a typeof expression.

[Visual Basic] 
' Creates a reference to the System.DateTime type.
Dim typeRef1 As New CodeTypeReference("System.DateTime")

' Creates a typeof expression for the specified type reference.
Dim typeof1 As New CodeTypeOfExpression(typeRef1)

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

'       GetType(System.DateTime)            

[C#] 
// Creates a reference to the System.DateTime type.
CodeTypeReference typeRef1 = new CodeTypeReference("System.DateTime");

// Creates a typeof expression for the specified type reference.
CodeTypeOfExpression typeof1 = new CodeTypeOfExpression(typeRef1);

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

//    typeof(System.DateTime);            

[C++] 
// Creates a reference to the System.DateTime type.
CodeTypeReference* typeRef1 = new CodeTypeReference(S"System.DateTime");

// Creates a typeof expression for the specified type reference.
CodeTypeOfExpression* typeof1 = new CodeTypeOfExpression(typeRef1);

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

//    typeof(System.DateTime);

[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

CodeTypeOfExpression Members | System.CodeDom Namespace | CodeTypeReferenceExpression

Show:
© 2014 Microsoft