vb.net - Set the second dimension of an array in a loop -


i want dinamycally set second array dimension depending on first dimension in loop. not able find documentation right now. don't mind being refered right place if has it.

dim array(3,0) string y integer = 0 array.getupperbound(0) - 1              <<set here second dimension of array dynamic variable              ( array(y).dimensionsize = x. y first dimension argument)>>              integer = 0 array.getupperbound(1) - 1                 array(y, i) = "something"             next         next 

is possible?

edit:

the situation group membership ad. user have multiple account.

the first loop go through number of account , second 1 through ad group in each of account.

userresult ad query result

this declaration @ begining since goes through backgroundworker. need global:

 public shared userinfogroup(1)() string 

the part i'm interested in within backgroundworker.dowork:

 redim userinfogroup(userresult.count)(1)          y integer = 0 userresult.count - 1              dim usergrouparray principalsearchresult(of principal) = userresult(y).getgroups()             redim userinfogroup(userresult.count)(usergrouparray.count)             integer = 0 usergrouparray.count - 1                 userinfogroup(y)(i) = usergrouparray(i).tostring()             next         next 

the backgroundworker.completed output array form.

if each "y" have different amount of "x" need jagged array, not 2d array.

dim array(3)() string  y integer = 0 array.getupperbound(0) - 1      redim array(y)(x)     ' or     ' array(y) = new string(x) {}      integer = 0 x         array(y)(i) = "something"     next next 

a better option have array of list.

dim array(3) list(of string)      y integer = 0 array.getupperbound(0) - 1      array(y) = new list(of string)      integer = 0 x         array(y).add("something")     next next 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -