and in my c# program, what i am trying to do is whenever in a game you say !mypickaxe, it tells you what pickaxe you have. Recently I figured out a way to save it to a .txt file so the data could be used more than one time, but of course im getting "object reference not set to an instance of an object". Here is the part that has the error:
StreamReader streemy = new StreamReader("pickaxes.txt");
string line = streemy.ReadLine();
string[] thing = line.Split('=');
player[userID].pickaxe = Convert.ToInt32(thing[1]);
In the .txt file, it saves like this: username=pickaxe And so it's supposed to get the number, but i get that error on this line:
string[] thing = line.Split('=');
Does anybody know how to fix this and/or why this happens? Thanks in advance!
streemy.ReadLine()returnsnullwhen end of file.line.SplitthrowsNullReferenceException