This isn't a sample of my code, but just a recreation of my problem. I'm very now to coding so it's probably just a dumb mistake, but I'm still posting this here just in case I can get an answer.
bool test;
int num;
num = Convert.ToInt32(Console.ReadKey());
if (num == 9) {
test = true;
}
//Error on line below: "Use of unassigned local variable 'test' [error]csharp(CS0165)"
if (test == true) {
Console.WriteLine("Random text");
}
I believe I get the error because I am trying to assign the variable within an if statement, but I do not know how to fix it or at the very least remove the boolean assignment outside the if statement.