Object reference not set to an instance of an object in C# -
string downloadedstring = "0;0;0;2610;-1515;15;4;0;0;none;0;0;torran|1;0;2;-3616;-3729;790;212;519;513;oa-4620;3405;4160;jzeero|"; string[] parts = downloadedstring.split('|'); string[][] users = new string[parts.length-1][]; (int = 0; < parts.length-1; i++) { string[] test = parts[i].split(';'); users[i][12] = test[12]; } i have code, splits strings, attempts store arrays..
when compiling, once program reaches following line:
users[i][12] = test[12]; visual c# tell me following:
nullreferenceexceptionunhandled: object reference not set instance of object.
why this? annoying, , friend knows c# doesn't know either
there no array @ users[0] (or users[1] . . .) [12] on users[i][12] trying index array doesn't exist.
replace
users[i][12] = test[12]; with
users[i] = test; that assign the entire new array created split user[i], can users[i][12] last element of array.
hope helps
Comments
Post a Comment