How to make this works? :
private string KeyChar = "";
public void SetMyKey(object sender, KeyEventArgs e) {
KeyChar = e.KeyCode; //ERROR
}
public void MyKeyDown(object sender, KeyEventArgs e) {
if (e.KeyCode = Keys.KeyChar) { //ERROR
Function();
}
}
Instead of using a method, I would use a property – you’ll also want to use the correct type here (Keys, instead of string). In addition, you need to use
==to check equality, since=is for assignment in C#: