Multidimensional arrays in VB.NET 2010
Is there any way to create a multidinensional array that contains arrays of different lengths (similar to nesting arrays of different lengths in python).
Because if I were to declare a variable Dim accounts(2,2) As Integer
all 1D arrays at each dimension have the same length. Is there any way to create an array so that this is not the case?
e.g The above code would create an array like this开发者_如何转开发:
[[0,0],[0,0]]
but would it be possible to create this:
[[0,0],[0,0,0]]
Apologies for the poor explanation but I cannot think of any better ways to explain.
You can use jagged arrays in .Net, but it might be better to use collections instead. That would make it easier to add & remove entries.
Try List(Of List(Of Integer))
I believe you're referring to a jagged array. And yes, .net supports this.
http://msdn.microsoft.com/en-us/library/wak0wfyt.aspx
And here's a quick example:
http://www.startvbdotnet.com/language/arrays.aspx
See Collection and Array Initializers in Visual Basic 2010.
精彩评论