I am a new student to C# and am looking for some guidance please.
In the example that I am working, I have a form that gets customer data filled in. That data then gets passed to a customer class. I need to store the input for x number of customers in an array, and later print out the information.The problem I keep finding is I can initialize the array, but when I return to the main program and then return with the next set of data, the array and the data is gone and I get an error.
How do I get the array to maintain the data until I either close the program or delete the array?
Thank you in advance for any assistance.
My code in the class is as follows:
public clsCustomers(string CustName, int AccountNo, int InputCount, int TotalCount, double AccountBalStart, double TotalPurchases, double TotalPaidMonth) //6 Parameters Passed
{
if (InputCount == 0)
{
CustData = new clsCustomers[TotalCount];
viCustomerCount = TotalCount;
}
else
CustData = new clsCustomers[InputCount];
CustData[InputCount] = new clsCustomers();
CustData[InputCount].CustName = CustName;
CustData[InputCount].AccountNumber = AccountNo;
CustData[InputCount].AccountBalStart = AccountBalStart;
CustData[InputCount].TotalPurchases = TotalPurchases;
CustData[InputCount].TotalPaidMonth = TotalPaidMonth;
CustData[InputCount].vdAccountBalMonth = AccountBalStart + TotalPurchases - TotalPaidMonth;
{
if (InputCount == 0)
{
CustData = new clsCustomers[TotalCount];
viCustomerCount = TotalCount;
}
else
CustData = new clsCustomers[InputCount];
CustData[InputCount] = new clsCustomers();
CustData[InputCount].CustName = CustName;
CustData[InputCount].AccountNumber = AccountNo;
CustData[InputCount].AccountBalStart = AccountBalStart;
CustData[InputCount].TotalPurchases = TotalPurchases;
CustData[InputCount].TotalPaidMonth = TotalPaidMonth;
CustData[InputCount].vdAccountBalMonth = AccountBalStart + TotalPurchases - TotalPaidMonth;
}

Manas MohapatraRank #182 · 13.2K reputationPosted Sep 28, 2015, 9:25 PM EDT
Wayne Wood16 reputationPosted Sep 28, 2015, 9:52 PM EDT
Manas MohapatraRank #182 · 13.2K reputationPosted Sep 28, 2015, 9:57 PM EDT
Wayne Wood16 reputationPosted Sep 28, 2015, 10:00 PM EDT
Wayne Wood16 reputationPosted Sep 28, 2015, 9:58 PM EDT
Manas MohapatraRank #182 · 13.2K reputationPosted Sep 28, 2015, 9:59 PM EDT
Wayne Wood16 reputationPosted Sep 30, 2015, 3:46 AM EDT