0
structs and arrays
I'm completing a question, it requires me to calculate profit from a set of three structs. they are, customer info, product info and order info. The code currently displayed, when running, only prints out the first product in a users order, then skips straight to a new line. the layout for order info is: order No. Customer ID, List of products separated by a comma.
10 odpowiedzi
+ 6
These lines were taken from LoadOrders :
string[] Values = Lines[i].Split(',');
pOrder[i].ordernumber = int.Parse(Values[0]);
pOrder[i].customerid = int.Parse(Values[1]);
pOrder[i].productorder = Values[2];
*And your final paragraph in the question :
"the layout for order info is: order No. Customer ID, List of products separated by a comma."
string[] Values = Lines[i].Split(',');
Splits the Lines[i] using comma as delimiter, so, when it sees that there's a comma, which you used as product list separator, it thinks that it is a new line, instead of product list separator.
Maybe, you need to come up with a new idea, what you should be using as product list separator. :)
Hope I get your question correctly,
Hth cmiiw
+ 2
Gordie, after 18 hours trying to do this question, it finally prints the correct order. thank you so much for your help
0
if I declare the array inside the struct, i.e public string[] product order; the array doesn't exist outside the struct, firstly, how would I get it to exist outside, and secondly, how would I add the values to the product order array
0
??????
0
I've updated the code, not sure if it's correct, but the array productorder doesn't exist still
0
it gets the stuff to write, however, it's writing system . string []
0
it does that, however, the output is system.string [ ]
rather than the id.
code has been updated
0
I would like it to print the products for each customer's order
0
no, it either generates huge spaces, or doesn't print all of a person's order