+ 1
Assistance needed! How do I get this console program to work? (C#)
Code URL: https://code.sololearn.com/c0uYJS7E2gmj/?ref=app I am new to coding C-Sharp. After learning a few things from SoloLearn i decided to set myself a project, which was to create a console based bank system. throughout creating and testing of the program it all seemed to work fine but I am now having a problem. As you can see from the code, I would like to be able to save the new balance in the class - BankAccount - however, when I chose to deposit or withdraw any values and get an output of the new balance it has always reset the balance back to '0' and I cannot figure out how to solve this problem. Any assistance with this will be highly appreciate.
2 ответов
0
It seems everytime you call your functions, you create a new object of the class BankAccount. It will start with a value 0 and will reset since you are creating a new object and the balance is not static. Try changing it to private static double.