net_array
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionLast revisionBoth sides next revision | ||
net_array [2018/02/04 17:49] – created wolfgangriedmann | net_array [2018/05/31 03:52] – wolfgangriedmann | ||
---|---|---|---|
Line 17: | Line 17: | ||
// Do something | // Do something | ||
next</ | next</ | ||
+ | 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: | ||
+ | < | ||
+ | cByte := Array.Find( aData, { a as byte => a == 2 } ) | ||
+ | cByte := Array.Find( aData, FindByte ) | ||
+ | |||
+ | static method FindByte( b as byte ) as logic | ||
+ | if b == 2 | ||
+ | return true | ||
+ | endif | ||
+ | return false</ | ||
+ | There are two different types of multidimensional arrays with different syntax: | ||
+ | The jagged arrays or arrays of arrays: | ||
+ | < | ||
+ | aJagged := < | ||
+ | System.Console.WriteLine( aJagged[0][0] )</ | ||
+ | The jagged arrays are more efficient, but have a (for xBase users) strange syntax to access the members. | ||
+ | There are also multidimensional arrays: | ||
+ | < | ||
+ | |||
+ | aMulti := string[, | ||
+ | System.Console.WriteLine( aMulti[0,0] )</ | ||
+ | Of course you can use them also in more than 2 dimensions. | ||
+ | |||
+ | In the daily coding the [[collections|Collections]] are much more important, because they can be resized. | ||
+ | |||
+ | But it is important to know how to deal with arrays because some methods return them or expect them as parameters, and because these are extremely efficient. | ||
+ | |||
+ | 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 informations about .NET arrays in the MSDN page [[https:// | ||
net_array.txt · Last modified: 2018/09/09 04:20 by wolfgangriedmann