0

How to use a variable from one method to another

for example if a have a var x in method 1 and how can i use that variable to another method 2?

4th May 2018, 2:15 PM
Sunny
Sunny - avatar
2 odpowiedzi
0
public void method2(int var) { var += 4; } public void method1() { int x = 4; method2(x); }
4th May 2018, 2:40 PM
TurtleShell
TurtleShell - avatar
0
If any variable is created inside a function, it will be destroyed when the function ends, so there is no way to do that.
4th May 2018, 2:55 PM
Bebida Roja
Bebida Roja - avatar