I would like to know the most efficient way of creating new arrays from the content of other arrays.
I have several arrays of strings of the type:
public readonly string[] Taiwan = { "TW", "TWO" };
public readonly string[] Vietnam = { "HM", "HN", "HNO" };
public readonly string[] Korea = { "KQ", "KS" };
public readonly string[] China = { "SS", "SZ" };
public readonly string[] Japan = { "T", "OS", "NG", "FU", "SP", "Q", "OJ", "JNX", "IXJ", "KAB", "JA", "JPx" };
It would be possible to create now a new array of string in a similar way to this?
public readonly string[] ASIA = { Taiwan, Vietnam, Korea, China, Japan};
That would contain all the strings included in the other arrays.
Ensure that the two arrays have the same rank (number of dimensions) and compatible element data types. Use a standard assignment statement to assign the source array to the destination array. Do not follow either array name with parentheses.
There are various ways in which an array can be declared and initialized in various ways. You can declare an array of any data type (i.e. int, float, double, char) in C.
To create an array, define the data type (like int ) and specify the name of the array followed by square brackets []. To insert values to it, use a comma-separated list, inside curly braces: int myNumbers[] = {25, 50, 75, 100};
string[] ASIA = new []{ Taiwan, Vietnam, Korea, China, Japan}
.SelectMany(s => s) // not entirely sure what these abbreviations are...
.ToArray();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With