vb.net - "System.NullReferenceException" while filling dictionary with keys from an array -


i have problem in code. here problematic snippet. reading of line work, @ point should fill zeilendict keys , values, throws "system.nullreferenceexception" , dont know why.

did wrong in loop, or dictionary not right iniziated? or arr1 empty?

module module1 public zeilendict dictionary(of string, integer) public insertdict dictionary(of string, string) public sub einlesen()      form1.id = 0     form1.openfiledialog1.showdialog()     form1.path = form1.openfiledialog1.filename     form1.openfiledialog1.dispose()      dim fs filestream = new filestream(form1.path, filemode.open, fileaccess.read)     dim sr streamreader = new streamreader(fs)      dim erstezeile = sr.readline()      form1.arr1 = erstezeile.split(new char() {";"c})      sr.close()     fs.close()      dim integer      = 0 form1.arr1.length - 1         form1.datagridview1.rows.add(form1.arr1(i))     next      dim i1 integer      i1 = 0 form1.arr1.length - 1         zeilendict.add(form1.arr1(i1), 0)     next 

it seems have not initiated dictionary. there adding items give nullrefexception

try adding:

public zeilendict dictionary(of string, integer) = new dictionary(of string, integer)() 

or set first line in method:

zeilendict = new dictionary(of string, integer)() 

also other dictionary


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -