CodeTypeReferenceExpression CodeTypeReferenceExpression CodeTypeReferenceExpression CodeTypeReferenceExpression Class

Definition

Represents a reference to a data type.

public ref class CodeTypeReferenceExpression : System::CodeDom::CodeExpression
[System.Runtime.InteropServices.ComVisible(true)]
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Serializable]
public class CodeTypeReferenceExpression : System.CodeDom.CodeExpression
type CodeTypeReferenceExpression = class
    inherit CodeExpression
Public Class CodeTypeReferenceExpression
Inherits CodeExpression
Inheritance
CodeTypeReferenceExpressionCodeTypeReferenceExpressionCodeTypeReferenceExpressionCodeTypeReferenceExpression
Attributes

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 = gcnew 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, gcnew CodeGeneratorOptions());
// The code generator produces the following source code for the preceeding example code:

//    System.DateTime

// 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

CodeTypeReferenceExpression() CodeTypeReferenceExpression() CodeTypeReferenceExpression() CodeTypeReferenceExpression()

Initializes a new instance of the CodeTypeReferenceExpression class.

CodeTypeReferenceExpression(CodeTypeReference) CodeTypeReferenceExpression(CodeTypeReference) CodeTypeReferenceExpression(CodeTypeReference) CodeTypeReferenceExpression(CodeTypeReference)

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

CodeTypeReferenceExpression(String) CodeTypeReferenceExpression(String) CodeTypeReferenceExpression(String) CodeTypeReferenceExpression(String)

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

CodeTypeReferenceExpression(Type) CodeTypeReferenceExpression(Type) CodeTypeReferenceExpression(Type) CodeTypeReferenceExpression(Type)

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

Properties

Type Type Type Type

Gets or sets the data type to reference.

UserData UserData UserData UserData

Gets the user-definable data for the current object.

(Inherited from CodeObject)

Methods

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to