CodeTypeOfExpression Class
Represents a typeof expression, an expression that returns a Type for a specified type name.
System.CodeDom::CodeObject
System.CodeDom::CodeExpression
System.CodeDom::CodeTypeOfExpression
Assembly: System (in System.dll)
The CodeTypeOfExpression type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | CodeTypeOfExpression() | Initializes a new instance of the CodeTypeOfExpression class. |
![]() | CodeTypeOfExpression(CodeTypeReference) | Initializes a new instance of the CodeTypeOfExpression class. |
![]() | CodeTypeOfExpression(String) | Initializes a new instance of the CodeTypeOfExpression class using the specified type. |
![]() | CodeTypeOfExpression(Type) | Initializes a new instance of the CodeTypeOfExpression class using the specified type. |
| Name | Description | |
|---|---|---|
![]() | Type | Gets or sets the data type referenced by the typeof expression. |
![]() | UserData | Gets the user-definable data for the current object. (Inherited from CodeObject.) |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | 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. CodeTypeReference^ typeRef1 = gcnew CodeTypeReference("System.DateTime"); // Creates a typeof expression for the specified type reference. CodeTypeOfExpression^ typeof1 = gcnew CodeTypeOfExpression(typeRef1); // Create a C# code provider CodeDomProvider^ provider = CodeDomProvider::CreateProvider("CSharp"); // Generate code and send the output to the console provider->GenerateCodeFromExpression(typeof1, Console::Out, gcnew CodeGeneratorOptions()); // The code generator produces the following source code for the preceeding example code: // typeof(System.DateTime)
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.
