Homework - C# - Creating an object instance with a button click

Posted by Erica on Stack Overflow See other posts from Stack Overflow or by Erica
Published on 2012-11-24T04:50:35Z Indexed on 2012/11/24 5:04 UTC
Read the original article Hit count: 175

I'm new to learning Windows Programming with C#. My current assignment is to create a very simple bank account program: The user enters the accountholder name, account number and beginning balance, then presses a "Continue" button to work with that account by making deposits and withdrawals. I wrote a separate "BankAccount" class with the required data members and methods. I've put the code for the creation of the BankAccount object in the Continue button click event

BankAccount currentAccount = new BankAccount(acctName, acctNum, beginningBalance);

But that seems to make it local to that method only, and currentAccount is not recognized when I'm programming the click event for the "Record Transactions" (deposits and withdrawals) button. How and where should the creation of the BankAccount object be coded in order for it to be created when the "Continue" button is clicked and also recognized in the "Record Transactions" button click event? Please let me know if any clarification is needed, or if you need to see part or all of my code.

© Stack Overflow or respective owner

Related posts about c#

Related posts about instance-variables