CodeTypeOfExpression Class

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

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

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

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

<SerializableAttribute>
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)>
<ComVisibleAttribute(True)>
Public Class CodeTypeOfExpression
	Inherits CodeExpression

NameDescription
System_CAPS_pubmethodCodeTypeOfExpression()

Initializes a new instance of the CodeTypeOfExpression class.

System_CAPS_pubmethodCodeTypeOfExpression(CodeTypeReference)

Initializes a new instance of the CodeTypeOfExpression class.

System_CAPS_pubmethodCodeTypeOfExpression(String)

Initializes a new instance of the CodeTypeOfExpression class using the specified type.

System_CAPS_pubmethodCodeTypeOfExpression(Type)

Initializes a new instance of the CodeTypeOfExpression class using the specified type.

NameDescription
System_CAPS_pubpropertyType

Gets or sets the data type referenced by the typeof expression.

System_CAPS_pubpropertyUserData

Gets the user-definable data for the current object.(Inherited from CodeObject.)

NameDescription
System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

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.

The following example demonstrates use of a CodeTypeOfExpression to represent a typeof expression.

' 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)

' Create a Visual Basic code provider
Dim provider As CodeDomProvider = CodeDomProvider.CreateProvider("VisualBasic")

' Generate code and send the output to the console
provider.GenerateCodeFromExpression(typeof1, Console.Out, new CodeGeneratorOptions())
' The code generator produces the following source code for the preceeding example code:
'    GetType(Date)

.NET Framework
Available since 1.1

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

Return to top
Show: