Redigera

CodeTypeReferenceExpression Class

Definition

Represents a reference to a data type.

public ref class CodeTypeReferenceExpression : System::CodeDom::CodeExpression
public class CodeTypeReferenceExpression : System.CodeDom.CodeExpression
type CodeTypeReferenceExpression = class
    inherit CodeExpression
Public Class CodeTypeReferenceExpression
Inherits CodeExpression
Inheritance
CodeTypeReferenceExpression

Examples

The following example demonstrates use of a CodeTypeReferenceExpression to represent a reference to a type.

// Creates an expression referencing the System.DateTime type.
CodeTypeReferenceExpression typeRef1 = new CodeTypeReferenceExpression("System.DateTime");

// Create a C# code provider
CodeDomProvider provider = CodeDomProvider.CreateProvider("CSharp");

// Generate code and send the output to the console
provider.GenerateCodeFromExpression(typeRef1, Console.Out, new CodeGeneratorOptions());
// The code generator produces the following source code for the preceeding example code:

//    System.DateTime
' Creates an expression referencing the System.DateTime type.
Dim typeRef1 As new CodeTypeReferenceExpression("System.DateTime")

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

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

'    Date

Remarks

CodeTypeReferenceExpression can be used to reference a particular data type.

The Type property specifies the data type to reference.

Constructors

Name Description
CodeTypeReferenceExpression()

Initializes a new instance of the CodeTypeReferenceExpression class.

CodeTypeReferenceExpression(CodeTypeReference)

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

CodeTypeReferenceExpression(String)

Initializes a new instance of the CodeTypeReferenceExpression class using the specified data type name.

CodeTypeReferenceExpression(Type)

Initializes a new instance of the CodeTypeReferenceExpression class using the specified data type.

Properties

Name Description
Type

Gets or sets the data type to reference.

UserData

Gets the user-definable data for the current object.

(Inherited from CodeObject)

Applies to