Because you've declared the variables locally to their methods. When you declare a variable like this:
class MyClass {
void MyFunc() {
int myVar = 5;
}
}myVar is only accessible within MyFunc(). If want myVar to be accessible to all methods in the class, you have to make it a property of the class:
class MyClass {
int myVar = 5;
void MyFunc() {
}
}