vb.net - Declaring multidimensional array -
i want loop array , fill data. have not been able find out, how declare multidimensional array when don't know width in advance.
here's have right now.
dim items()() string y integer = 0 object.count - 1 items(y)(0) = "something" items(y)(1) = "something" items(y)(2) = "something" items(y)(3) = "something" items(y)(4) = "something" items(y)(5) = "something" items(y)(6) = "something" next
i've been suggested (x, x) i'm not sure how declare without width. how should this?
looks want 2-dimensional array keep track of multiple arrays of strings. if know total count of arrays have, this:
dim items(object.count - 1, 6) string y integer = 0 object.count - 1 items(y, 0) = "something" items(y, 1) = "something" items(y, 2) = "something" items(y, 3) = "something" items(y, 4) = "something" items(y, 5) = "something" items(y, 6) = "something" next
honestly better use list (of list(of string))
, multidimensional arrays have have first index's upper bound declared when initialize it. second indexes upper bound can redimmed.
using list setup like:
dim items new list(of list(of string)) y integer = 0 object.count - 1 dim tmplist new list(of string) tmplist.add("something") tmplist.add("something") tmplist.add("something") tmplist.add("something") tmplist.add("something") tmplist.add("something") tmplist.add("something") items.add(tmplist) next
or, better yet, the_lotus mentioned in comments above, create class if possible hold 7 (or many) values going inner list or array, need list(of string)
hold each instance.
Comments
Post a Comment