CodeArrayCreateExpression Classe
Definição
Representa uma expressão que cria uma matriz.Represents an expression that creates an array.
public ref class CodeArrayCreateExpression : System::CodeDom::CodeExpression
public class CodeArrayCreateExpression : System.CodeDom.CodeExpression
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodeArrayCreateExpression : System.CodeDom.CodeExpression
type CodeArrayCreateExpression = class
inherit CodeExpression
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type CodeArrayCreateExpression = class
inherit CodeExpression
Public Class CodeArrayCreateExpression
Inherits CodeExpression
- Herança
- Atributos
Exemplos
O código a seguir usa um CodeArrayCreateExpression para criar uma matriz de inteiros com 10 índices.The following code uses a CodeArrayCreateExpression to create an array of integers with 10 indexes.
// Create an initialization expression for a new array of type Int32 with 10 indices
CodeArrayCreateExpression^ ca1 = gcnew CodeArrayCreateExpression( "System.Int32",10 );
// Declare an array of type Int32, using the CodeArrayCreateExpression ca1 as the initialization expression
CodeVariableDeclarationStatement^ cv1 = gcnew CodeVariableDeclarationStatement( "System.Int32[]","x",ca1 );
// A C# code generator produces the following source code for the preceeding example code:
// int[] x = new int[10];
// Create an initialization expression for a new array of type Int32 with 10 indices
CodeArrayCreateExpression ca1 = new CodeArrayCreateExpression("System.Int32", 10);
// Declare an array of type Int32, using the CodeArrayCreateExpression ca1 as the initialization expression
CodeVariableDeclarationStatement cv1 = new CodeVariableDeclarationStatement("System.Int32[]", "x", ca1);
// A C# code generator produces the following source code for the preceeding example code:
// int[] x = new int[10];
' Create an initialization expression for a new array of type Int32 with 10 indices
Dim ca1 As New CodeArrayCreateExpression("System.Int32", 10)
' Declare an array of type Int32, using the CodeArrayCreateExpression ca1 as the initialization expression
Dim cv1 As New CodeVariableDeclarationStatement("System.Int32[]", "x", ca1)
' A Visual Basic code generator produces the following source code for the preceeding example code:
' Dim x() As Integer = New Integer(9) {}
Comentários
CodeArrayCreateExpression pode ser usado para representar uma expressão de código que cria uma matriz.CodeArrayCreateExpression can be used to represent a code expression that creates an array. As expressões que criam uma matriz devem especificar um número de elementos ou uma lista de expressões a serem usadas para inicializar a matriz.Expressions that create an array should specify either a number of elements, or a list of expressions to use to initialize the array.
A maioria das matrizes pode ser inicializada imediatamente após a declaração.Most arrays can be initialized immediately following declaration. A Initializers propriedade pode ser definida como a expressão a ser usada para inicializar a matriz.The Initializers property can be set to the expression to use to initialize the array.
CodeArrayCreateExpressionApenas dá suporte diretamente à criação de matrizes de dimensão única.A CodeArrayCreateExpression only directly supports creating single-dimension arrays. Se uma linguagem permitir matrizes de matrizes, é possível criá-las aninhando um CodeArrayCreateExpression dentro de um CodeArrayCreateExpression .If a language allows arrays of arrays, it is possible to create them by nesting a CodeArrayCreateExpression within a CodeArrayCreateExpression. Nem todos os idiomas oferecem suporte a matrizes de matrizes.Not all languages support arrays of arrays. Você pode verificar se um ICodeGenerator para um idioma declara o suporte para matrizes aninhadas chamando Supports com o ArraysOfArrays sinalizador.You can check whether an ICodeGenerator for a language declares support for nested arrays by calling Supports with the ArraysOfArrays flag.
Construtores
| CodeArrayCreateExpression() |
Inicializa uma nova instância da classe CodeArrayCreateExpression.Initializes a new instance of the CodeArrayCreateExpression class. |
| CodeArrayCreateExpression(CodeTypeReference, CodeExpression) |
Inicializa uma nova instância da classe CodeArrayCreateExpression usando o tipo de dados da matriz especificado e a expressão de código indicando o número de índices para a matriz.Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type and code expression indicating the number of indexes for the array. |
| CodeArrayCreateExpression(CodeTypeReference, CodeExpression[]) |
Inicializa uma nova instância da classe CodeArrayCreateExpression usando as expressões de inicialização e o tipo de dados da matriz especificados.Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type and initialization expressions. |
| CodeArrayCreateExpression(CodeTypeReference, Int32) |
Inicializa uma nova instância da classe CodeArrayCreateExpression usando o tipo de dados da matriz especificado e o número de índices para a matriz.Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type and number of indexes for the array. |
| CodeArrayCreateExpression(String, CodeExpression) |
Inicializa uma nova instância da classe CodeArrayCreateExpression usando o nome do tipo de dados da matriz especificado e a expressão de código indicando o número de índices para a matriz.Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type name and code expression indicating the number of indexes for the array. |
| CodeArrayCreateExpression(String, CodeExpression[]) |
Inicializa uma nova instância da classe CodeArrayCreateExpression usando os inicializadores e o nome do tipo de dados da matriz especificados.Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type name and initializers. |
| CodeArrayCreateExpression(String, Int32) |
Inicializa uma nova instância da classe CodeArrayCreateExpression usando o nome do tipo de dados da matriz especificado e o número de índices para a matriz.Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type name and number of indexes for the array. |
| CodeArrayCreateExpression(Type, CodeExpression) |
Inicializa uma nova instância da classe CodeArrayCreateExpression usando o tipo de dados da matriz especificado e a expressão de código indicando o número de índices para a matriz.Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type and code expression indicating the number of indexes for the array. |
| CodeArrayCreateExpression(Type, CodeExpression[]) |
Inicializa uma nova instância da classe CodeArrayCreateExpression usando os inicializadores e o tipo de dados da matriz especificados.Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type and initializers. |
| CodeArrayCreateExpression(Type, Int32) |
Inicializa uma nova instância da classe CodeArrayCreateExpression usando o tipo de dados da matriz especificado e o número de índices para a matriz.Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type and number of indexes for the array. |
Propriedades
| CreateType |
Obtém ou define o tipo da matriz a ser criada.Gets or sets the type of array to create. |
| Initializers |
Obtém os inicializadores com os quais inicializar a matriz.Gets the initializers with which to initialize the array. |
| Size |
Obtém ou define o número de índices na matriz.Gets or sets the number of indexes in the array. |
| SizeExpression |
Obtém ou define a expressão que indica o tamanho da matriz.Gets or sets the expression that indicates the size of the array. |
| UserData |
Obtém os dados definidos pelo usuário para o objeto atual.Gets the user-definable data for the current object. (Herdado de CodeObject) |
Métodos
| Equals(Object) |
Determina se o objeto especificado é igual ao objeto atual.Determines whether the specified object is equal to the current object. (Herdado de Object) |
| GetHashCode() |
Serve como a função de hash padrão.Serves as the default hash function. (Herdado de Object) |
| GetType() |
Obtém o Type da instância atual.Gets the Type of the current instance. (Herdado de Object) |
| MemberwiseClone() |
Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object. (Herdado de Object) |
| ToString() |
Retorna uma cadeia de caracteres que representa o objeto atual.Returns a string that represents the current object. (Herdado de Object) |