System.CodeDom.CodeArrayCreateExpression Class

Assembly: System.dll
Namespace: System.CodeDom
Summary
Represents an expression that creates an array.
C# Syntax:
[Serializable]
public class CodeArrayCreateExpression : CodeExpression
Remarks
CodeArrayCreateExpression can be used to represent a code expression that creates an array. Expressions that create an array should specify either a number of elements, or a list of expressions to use for initialization.

Only signle-dimensional arrays can be created with a CodeArrayCreateExpression. It is possible to create arrays of arrays by nesting a CodeArrayCreateExpression within another. Not all languages support arrays of arrays. Support for nested arrays should be checked for by calling ICodeGenerator.Supports with the GeneratorSupport.ArraysOfArrays flag.

Most arrays can be initialized immediately following declaration. The CodeArrayCreateExpression.Initializers property can be set to the expression to use to initialize the array.

Example
The following code creates a CodeArrayCreateExpression named array1 for an array of integers with 10 indices:
          CodeArrayCreateExpression array1 = new CodeArrayCreateExpression( typeof(int), 10);
        

The CodeDOM representation created in the above example will generate the following source code:

[C#]

new int[10];

See also:
System.CodeDom Namespace

System.CodeDom.CodeArrayCreateExpression Member List:

Public Constructors
ctor #1 Overloaded:
.ctor()

Default constructor. This constructor is called by derived class constructors to initialize state in this type.
Initializes a new instance of the CodeArrayCreateExpression class.
ctor #2 Overloaded:
.ctor(CodeTypeReference createType, CodeExpression size)

Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type and code expression indicating the number of indices for the array.
ctor #3 Overloaded:
.ctor(CodeTypeReference createType, params CodeExpression[] initializers)

Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type and initialization expressions.
ctor #4 Overloaded:
.ctor(CodeTypeReference createType, int size)

Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type and number of indices for the array.
ctor #5 Overloaded:
.ctor(string createType, CodeExpression size)

Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type name and code expression indicating the number of indices for the array.
ctor #6 Overloaded:
.ctor(string createType, params CodeExpression[] initializers)

Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type name and initializers.
ctor #7 Overloaded:
.ctor(string createType, int size)

Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type name and number of indices for the array.
ctor #8 Overloaded:
.ctor(Type createType, CodeExpression size)

Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type and code expression indicating the number of indices for the array.
ctor #9 Overloaded:
.ctor(Type createType, params CodeExpression[] initializers)

Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type and initializers.
ctor #10 Overloaded:
.ctor(Type createType, int size)

Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type and number of indicies for the array.
Public Properties
CreateType Read-write

Gets or sets the type of array to create.
Initializers Read-only

Gets the initializers with which to initialize the array.
Size Read-write

Gets or sets the number of indices in the array.
SizeExpression Read-write

Gets or sets the expression that indicates the size of the array.
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.CodeArrayCreateExpression Member Details

Overloaded ctor #1
Summary
Initializes a new instance of the CodeArrayCreateExpression class.

Default constructor. This constructor is called by derived class constructors to initialize state in this type.
C# Syntax:
public CodeArrayCreateExpression();

Return to top


Overloaded ctor #2
Summary
Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type and code expression indicating the number of indices for the array.
C# Syntax:
public CodeArrayCreateExpression(
   CodeTypeReference createType,
   CodeExpression size
);
Parameters:

createType

A CodeTypeReference indicating the data type of the array to create.

size

An expression that indicates the number of indices of the array to create.

Return to top


Overloaded ctor #3
Summary
Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type and initialization expressions.
C# Syntax:
public CodeArrayCreateExpression(
   CodeTypeReference createType,
   params CodeExpression[] initializers
);
Parameters:

createType

A CodeTypeReference that indicates the data type of the array to create.

initializers

An array of expressions to use to initialize the array.

Return to top


Overloaded ctor #4
Summary
Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type and number of indices for the array.
C# Syntax:
public CodeArrayCreateExpression(
   CodeTypeReference createType,
   int size
);
Parameters:

createType

A CodeTypeReference indicating the data type of the array to create.

size

The number of indices of the array to create.

Return to top


Overloaded ctor #5
Summary
Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type name and code expression indicating the number of indices for the array.
C# Syntax:
public CodeArrayCreateExpression(
   string createType,
   CodeExpression size
);
Parameters:

createType

The name of the data type of the array to create.

size

An expression that indicates the number of indices of the array to create.

Return to top


Overloaded ctor #6
Summary
Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type name and initializers.
C# Syntax:
public CodeArrayCreateExpression(
   string createType,
   params CodeExpression[] initializers
);
Parameters:

createType

The name of the data type of the array to create.

initializers

An array of expressions to use to initialize the array.

Return to top


Overloaded ctor #7
Summary
Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type name and number of indices for the array.
C# Syntax:
public CodeArrayCreateExpression(
   string createType,
   int size
);
Parameters:

createType

The name of the data type of the array to create.

size

The number of indices of the array to create.

Return to top


Overloaded ctor #8
Summary
Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type and code expression indicating the number of indices for the array.
C# Syntax:
public CodeArrayCreateExpression(
   Type createType,
   CodeExpression size
);
Parameters:

createType

The data type of the array to create.

size

An expression that indicates the number of indices of the array to create.

Return to top


Overloaded ctor #9
Summary
Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type and initializers.
C# Syntax:
public CodeArrayCreateExpression(
   Type createType,
   params CodeExpression[] initializers
);
Parameters:

createType

The data type of the array to create.

initializers

An array of expressions to use to initialize the array.

Return to top


Overloaded ctor #10
Summary
Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type and number of indicies for the array.
C# Syntax:
public CodeArrayCreateExpression(
   Type createType,
   int size
);
Parameters:

createType

The data type of the array to create.

size

The number of indices of the array to create.

Return to top


Property: CreateType (read-write)
Summary
Gets or sets the type of array to create.
C# Syntax:
public CodeTypeReference CreateType {get; set;}

Return to top


Property: Initializers (read-only)
Summary
Gets the initializers with which to initialize the array.
C# Syntax:
public CodeExpressionCollection Initializers {get;}

Return to top


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

Return to top


Property: SizeExpression (read-write)
Summary
Gets or sets the expression that indicates the size of the array.
C# Syntax:
public CodeExpression SizeExpression {get; set;}
Remarks
The size of the array can be represented with a CodeExpression.

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:
~CodeArrayCreateExpression();

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.