List box Object reference not set to an instance of an object

You have not instantiated itemname. You need to do this (3 is just a random number):

public static string[] itemname = new string[3];

If you didn’t do this, you should have received the error on this line:

itemname[id] = "foo";

Leave a Comment