xsharp.eu • Multidimensional array syntax
Page 1 of 1

Multidimensional array syntax

Posted: Tue Jan 25, 2022 7:54 am
by Bernhard Mayer
Dear fellow X#'ers!

In times of collections and lists I barely have any need for it but what's the syntax for creating and initializing a multidimensional .NET array?

I tried something like

Code: Select all

LOCAL aData AS STRING[,]
aData := <STRING>{  {"OneOne", "OneTwo"}, {"TwoOne", "TwoTwo"} } // Doesn't work
aData := STRING[,]{2,2} {  {"OneOne", "OneTwo"}, {"TwoOne", "TwoTwo"} } // Nor this
aData := STRING[,]{2,2} {  <STRING>{"OneOne", "OneTwo"}, <STRING>{"TwoOne", "TwoTwo"} } // Nor this
It's very embarrassing but what is the correct syntax?

TIA,
Bernhard
(X# 2.9)

Multidimensional array syntax

Posted: Tue Jan 25, 2022 8:07 am
by Chris
Hi Bernhard,

Actually your 2nd version of the initializer does compile and run fine :)

Multidimensional array syntax

Posted: Tue Jan 25, 2022 8:14 am
by Bernhard Mayer
Interesting, it does compile now ... well, the problem is definitely located before the computer :oops:

THX & best regards,
Bernhard

Multidimensional array syntax

Posted: Tue Jan 25, 2022 8:24 am
by Chris
To be honest, I was about to open a ticket about none of those 3 versions working here either, until I realized the 2nd one does work in the last moment :)