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.

5th Dec 2017, 7:07 PM
Roguesquid
Roguesquid - avatar
17 Answers
+ 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
5th Dec 2017, 8:45 PM
Ipang
+ 2
Gordie, after 18 hours trying to do this question, it finally prints the correct order. thank you so much for your help
8th Dec 2017, 7:47 PM
Roguesquid
Roguesquid - avatar
5th Dec 2017, 7:08 PM
Roguesquid
Roguesquid - avatar
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
7th Dec 2017, 2:31 PM
Roguesquid
Roguesquid - avatar
0
??????
8th Dec 2017, 1:21 PM
Roguesquid
Roguesquid - avatar
0
I've updated the code, not sure if it's correct, but the array productorder doesn't exist still
8th Dec 2017, 1:38 PM
Roguesquid
Roguesquid - avatar
0
it gets the stuff to write, however, it's writing system . string []
8th Dec 2017, 2:51 PM
Roguesquid
Roguesquid - avatar
0
it does that, however, the output is system.string [ ] rather than the id. code has been updated
8th Dec 2017, 3:09 PM
Roguesquid
Roguesquid - avatar
0
I would like it to print the products for each customer's order
8th Dec 2017, 3:36 PM
Roguesquid
Roguesquid - avatar
0
no, it either generates huge spaces, or doesn't print all of a person's order
8th Dec 2017, 7:25 PM
Roguesquid
Roguesquid - avatar