User Tools

Site Tools


net_array

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
net_array [2018/02/04 18:22] wolfgangriedmannnet_array [2018/05/31 03:52] wolfgangriedmann
Line 29: Line 29:
 return false</code> return false</code>
  
 +There are two different types of multidimensional arrays with different syntax:
 +The jagged arrays or arrays of arrays:
 +<code>local aJagged as string[][]
  
 +aJagged := <string[]>{ <string>{ "X#", "xsharp.info" }, <string>{ "C#", "microsoft.com" } }
 +System.Console.WriteLine( aJagged[0][0] )</code>
 +The jagged arrays are more efficient, but have a (for xBase users) strange syntax to access the members.
 +There are also multidimensional arrays:
 +<code>local aMulti as string[,]
  
 +aMulti := string[,]{2,2}{ <string>{ "X#", "xsharp.info" }, <string>{ "C#", "microsoft.com" } }
 +System.Console.WriteLine( aMulti[0,0] )</code>
 +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: every member is an usual (with the known overhead at runtime and in memory) and therefore any type checking must be done at runtime by the programmers code (for the .NET arrays the compiler does these checks).
 +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://docs.microsoft.com/en-us/dotnet/api/system.array|System.Array]]
  
  
net_array.txt · Last modified: 2018/09/09 04:20 by wolfgangriedmann