fbpx

Creating an empty .net array: syntax?

More
4 months 1 week ago #1 by Kurt Kitzberger
Creating an empty .net array: syntax? was created by Kurt Kitzberger
Hi!
How do I create an empty .net array with count of elements out of a variable?
VO:
local aArray as array
iElements := 100
aArray := ArrayCreate( iElements )

X#:
local aX as string[]
iElements := 100
aX := ???

I am aware of
aX := <string>{"Alpha", "Beta"}
but how do I create one without literals?

BR Kurt

Please Log in or Create an account to join the conversation.

More
4 months 1 week ago #2 by Wolfgang Riedmann
Replied by Wolfgang Riedmann on topic Creating an empty .net array: syntax?
Hi Kurt,
aData := string[]{ 10 }

Please see also here: docs.xsharp.it/doku.php?id=net_array

Wolfgang

Please Log in or Create an account to join the conversation.

More
4 months 1 week ago #3 by Kurt Kitzberger
Replied by Kurt Kitzberger on topic Creating an empty .net array: syntax?
Thanks Wolfgang!
Now it works!
Was already looking in these docs, but blind...
I had tried aX := <string[]>{ iElements }
There I got "cannot implicitly convert type 'int' to 'string[]'

BR Kurt

Please Log in or Create an account to join the conversation.

More
4 months 1 week ago #4 by Wolfgang Riedmann
Replied by Wolfgang Riedmann on topic Creating an empty .net array: syntax?
Hi Kurt,

the wiki has a search box in the upper right corner <g>.

Put "array" there and click on the search button. The correct article will be at top with 15 hits.

Wolfgang

Please Log in or Create an account to join the conversation.