Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a constant array of strings

Is there a way in Delphi declaring an array of strings such as following one?

{'first','second','third'} 
like image 660
none Avatar asked Nov 01 '10 15:11

none


People also ask

How do you declare a constant array?

In C#, use readonly to declare a const array. public static readonly string[] a = { "Car", "Motorbike", "Cab" }; In readonly, you can set the value at runtime as well unlike const.

How do you create an array of strings in C?

Here is how an array of C string can be initialized: #define NUMBER_OF_STRING 4 #define MAX_STRING_SIZE 40 char arr[NUMBER_OF_STRING][MAX_STRING_SIZE] = { "array of c string", "is fun to use", "make sure to properly", "tell the array size" };

How do you declare a constant array in C++?

In C++, the most common way to define a constant array should certainly be to, erm, define a constant array: const int my_array[] = {5, 6, 7, 8};


2 Answers

try this

Const Elements =3; MyArray  : array  [1..Elements] of string = ('element 1','element 2','element 3'); 
like image 110
RRUZ Avatar answered Sep 23 '22 09:09

RRUZ


In XE7 you can declare a dynamic array constant like this:

const   MyArray: TArray<String> = ['First','Second','Third']; 
like image 27
LU RD Avatar answered Sep 21 '22 09:09

LU RD