© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
11 replies
Question

❔ ✅ How to store a method's variable to main method?

I'm creating a simple ATM program, but I've encountered an issue:

I have created a method called "withdraw", the purpose of this method is to subtract a "WithdrawAmount" entered via the parameter to the users current balance.

I've managed to correctly have it subtract the balance, but I do not know how to store that result as a variable and bring it back to my main method?

the aim is to update the balance in my main method to the new balance after a withdraw has been made

I've attempted to use a
return
return
statement, but no luck.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How to use a variable from another method
C#CC# / help
4y ago
✅ Change a variable in method.
C#CC# / help
4y ago
unable to call main method
C#CC# / help
3y ago