.net - ConvertAll fails with NullReferenceException -
i trying flatten multi-dimensional array convertall can't work:
private function flatten(byref object) object dim elements integer = 0 dim size integer r = 0 a.rank - 1 size = a.getupperbound(r) - a.getlowerbound(r) + 1 if elements = 0 elements = size else elements = elements * size end if next dim result(elements - 1) object ' fails ! result = a.convertall(a, new converter(of object, object)(function(x) x)) return result end function sub main() dim a(,) integer = {{1, 2, 3}, {4, 5, 6}} dim b(5) integer b = flatten(a) end sub
why throw nullreferenceexception?
thanks
according msdn documentation, array.convertall()
takes 0 based one-dimensional array tinput
. have a(,)
defined 2 dimensional
Comments
Post a Comment