System.CodeDom.CodeTypeReference Class

Assembly: System.dll
Namespace: System.CodeDom
Summary
Represents a data type to CodeDOM objects.
C# Syntax:
[Serializable]
public class CodeTypeReference : CodeObject
Remarks
CodeTypeReference can be used to represent a data type to many types of CodeDOM objects.

Many objects or properties throughout the System.CodeDom namespace use this type of object to store data types. A CodeTypeReference can be initialized with a System.Type object or a string. It is generally recommeneded to use a System.Type to do this although it may not always be possible. If initializing an instance of this object with a string, it is strongly recommended to always use fully qualified types, such as "System.Console" instead of just "Console", as not all languages support importing namespaces.

Array types can be specified by either passing in an array of System.Type or using one of the constructors that accept rank as a parameter.

See also:
System.CodeDom Namespace

System.CodeDom.CodeTypeReference Member List:

Public Constructors
ctor #1 Overloaded:
.ctor(string typeName)

Initializes a new instance of the CodeTypeReference class using the specified data type name.
ctor #2 Overloaded:
.ctor(Type type)

Initializes a new instance of the CodeTypeReference class using the specified data type.
ctor #3 Overloaded:
.ctor(CodeTypeReference arrayType, int rank)

Initializes a new instance of the CodeTypeReference class using the specified array data type and array rank.
ctor #4 Overloaded:
.ctor(string baseType, int rank)

Initializes a new instance of the CodeTypeReference class using the specified array data type and array rank.
Public Properties
ArrayElementType Read-write

Gets or sets the data type of the elements in the array.
ArrayRank Read-write

Gets or sets the array rank of the array.
BaseType Read-write

Gets or sets the name of the data type being referenced.
UserData
(inherited from System.CodeDom.CodeObject)
Read-only

See base class member description: System.CodeDom.CodeObject.UserData


Gets or sets the user-definable data for the current object.
Public Methods
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
GetHashCode
(inherited from System.Object)
See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
Protected Methods
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.

Hierarchy:


System.CodeDom.CodeTypeReference Member Details

Overloaded ctor #1
Summary
Initializes a new instance of the CodeTypeReference class using the specified data type name.
C# Syntax:
public CodeTypeReference(
   string typeName
);
Parameters:

typeName

The name of the type to reference.

Return to top


Overloaded ctor #2
Summary
Initializes a new instance of the CodeTypeReference class using the specified data type.
C# Syntax:
public CodeTypeReference(
   Type type
);
Parameters:

type

The data type to reference.

Return to top


Overloaded ctor #3
Summary
Initializes a new instance of the CodeTypeReference class using the specified array data type and array rank.
C# Syntax:
public CodeTypeReference(CodeTypeReference(
   CodeTypeReference arrayType,
   int rank
);
Parameters:

arrayType

A CodeTypeReference that indicates the type of the array.

rank

The number of dimensions in the array.

Remarks
This constructor can be used to construct arrays of arrays by nesting CodeTypeReference objects.

Return to top


Overloaded ctor #4
Summary
Initializes a new instance of the CodeTypeReference class using the specified array data type and array rank.
C# Syntax:
public CodeTypeReference(
   string baseType,
   int rank
);
Parameters:

baseType

The data type of the elements of the array.

rank

The number of dimensions of the array.

Return to top


Property: ArrayElementType (read-write)
Summary
Gets or sets the data type of the elements in the array.
C# Syntax:
public CodeTypeReference ArrayElementType {get; set;}
Remarks
This is disregarded unless the CodeTypeReference.ArrayRank property is greater than or equal to 1.

Return to top


Property: ArrayRank (read-write)
Summary
Gets or sets the array rank of the array.
C# Syntax:
public int ArrayRank {get; set;}

Return to top


Property: BaseType (read-write)
Summary
Gets or sets the name of the data type being referenced.
C# Syntax:
public string BaseType {get; set;}
Remarks
This property will contain the name of the type unless it is an array type, in which case it will be the array element type.

Note The name of the property may be misleading. This property contains just the type name with any array adornments removed, not the base or parent type as might be expected.

Return to top


Property: UserData (read-only)
Inherited
See base class member description: System.CodeDom.CodeObject.UserData

Summary
Gets or sets the user-definable data for the current object.
C# Syntax:
public IDictionary UserData {get;}
Remarks


Notes to inheritors: An inheritor can design the way this user data is stored, retrieved, and used.

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~CodeTypeReference();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.