net_array
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| net_array [2018/05/31 03:50] – wolfgangriedmann | net_array [2018/09/09 04:20] (current) – wolfgangriedmann | ||
|---|---|---|---|
| Line 8: | Line 8: | ||
| A static array is defined by any datatype, followed by an open and a close square bracket: | A static array is defined by any datatype, followed by an open and a close square bracket: | ||
| - | < | + | < |
| To initialize such an array, you need to specify also the dimension, or to specify the values, casting to the right datatype: | To initialize such an array, you need to specify also the dimension, or to specify the values, casting to the right datatype: | ||
| - | < | + | < |
| aData := < | aData := < | ||
| It depends on the compiler settings of your application, | It depends on the compiler settings of your application, | ||
| Therefore it is better to use the '' | Therefore it is better to use the '' | ||
| - | < | + | < |
| // Do something | // Do something | ||
| next</ | next</ | ||
| Since an array is also an object, it has its own properties and methods. | Since an array is also an object, it has its own properties and methods. | ||
| But the static methods of the array class are much more interesting: | But the static methods of the array class are much more interesting: | ||
| - | < | + | < |
| cByte := Array.Find( aData, { a as byte => a == 2 } ) | cByte := Array.Find( aData, { a as byte => a == 2 } ) | ||
| cByte := Array.Find( aData, FindByte ) | cByte := Array.Find( aData, FindByte ) | ||
| Line 31: | Line 31: | ||
| There are two different types of multidimensional arrays with different syntax: | There are two different types of multidimensional arrays with different syntax: | ||
| The jagged arrays or arrays of arrays: | The jagged arrays or arrays of arrays: | ||
| - | < | + | < |
| aJagged := < | aJagged := < | ||
| System.Console.WriteLine( aJagged[0][0] )</ | System.Console.WriteLine( aJagged[0][0] )</ | ||
| The jagged arrays are more efficient, but have a (for xBase users) strange syntax to access the members. | The jagged arrays are more efficient, but have a (for xBase users) strange syntax to access the members. | ||
| + | <code visualfoxpro> | ||
| + | aJagged := < | ||
| + | At this level, there are no strings in aJagged. Only NULL values. | ||
| + | |||
| + | And now (if zero based), it can be filled: | ||
| + | <code visualfoxpro> | ||
| + | |||
| + | aJagger[0][0] := "First String element in the 1st array" | ||
| + | aJagged[1][2] := "Hello !" | ||
| + | aJagged[2][nLen-1] := "Last String element in the last array"</ | ||
| + | |||
| There are also multidimensional arrays: | There are also multidimensional arrays: | ||
| - | < | + | < |
| aMulti := string[, | aMulti := string[, | ||
| Line 48: | Line 59: | ||
| The VO dynamic arrays pay a high price for their flexibility: | The VO dynamic arrays pay a high price for their flexibility: | ||
| + | But the X# runtime (ready from June 2018) introduces typed arrays, so you can have both: the flexibility of the VO array and the compiler checks of the .NET array. | ||
| - | You can find more help in the MSDN page [[https:// | + | You can find more help informations about .NET arrays |
net_array.1527738639.txt.gz · Last modified: 2018/05/31 03:50 by wolfgangriedmann