+ 3
How can I do a variable that can be use un all forms? (C#)
For example: Supposed to have 2 forms, We have Form A and Form B. In Form A I do a variable called "pancake". And I want to call that variable in Form B, how can I do that?
4 Respuestas
+ 12
in form a:
class A {
private int n;
public int getN() {
return n;
}
}
in form b:
A a = new A();
int b = a.getN();
+ 10
by using object-oriented programming in way: create object in form b of form a, in form a write get method for that variable which will return variable value and call that method in form b with object which did you create
+ 2
Can you give me a Code example?
+ 2
Thanks!