Here's my code:
void gkh_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == neededLetter as Keys)
{
if (neededLetter == "n")
{
neededLetter = "o";
}
else if (neededLetter == "o")
{
neededLetter = "t";
}
else if (neededLetter == "t")
{
neededLetter = "e";
}
else if (neededLetter == "e")
{
this.Show();
}
}
else
{
neededLetter = "n";
}
}
I'm getting an error on the first If block:
The as operator must be used with a reference type or nullable type
Edit: To be clearer:
User presses a key and the computer compares that e.Keycode to a string variable with the letter "n" set to it. If true, set the variable neededLetter to "o".
After that, when a user pressed another key if it is "o", save neededletter to "t". and so on and so forth.