TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Wayne Wood
NA
16
752
Passing parameters to C# class arrays
Sep 28 2015 8:59 PM
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;
}
Reply
Answers (
7
)
HTML Button control Query
Export