Class with array RRS feed

  • Question

  • Hello 

    i have this struct with class, but i can't pass the array to second array

         public class store
                public Customers[] customers { get; set; }
                public class Customers
                    public string username { get; set; }
                    public string id_customer_access { get; set; }
                    public Sales[] sales { get; set; }
                    public  class Sales
                        public string idSales { get; set; }
                        public string ammount { get; set; }
     List<Sales> arraySales = new List<Sales>();
      Store.Customers storeCustomer = new  Store.Customers();
                    for (int i = 0; i < tb.Rows.Count; i++)
                        Sales sale = new Sales();
                        sale.idSales  =tb.Rows[i]["user"].ToString();
    storeCustomer.Sales= arraySales;

    storeCustomer.Sales= arraySales;

    This part fail to insert, how can i do it fine?


    • Edited by Mythocode Sunday, June 25, 2017 7:27 PM
    Sunday, June 25, 2017 7:26 PM

All replies

  • Well apart from this is the wrong forum for this question, some horrible code and using the wrong terms your next problem is you are not using the same types. I'm guessing the error is telling you *exactly* what the problem is. That you to need to change the list *To* an *Array*

    Monday, June 26, 2017 8:21 AM
  • Please take the time to explain what you need to do using words instead of just posting code.

    Sam Hobbs

    Tuesday, June 27, 2017 2:04 AM
  • Hello,

    I want to fill a structure with the data I get from the database, customer and sales and put in json format.

    On the side I want to create an list of clients with their information, name, id, street .. and inside of each customer another list with the products bought bu each customer, order, articles, price, quantity.

    the first i filled the customer class with the entire list of customers, and then I try to fill the list of sales with the order purchased.

    The final goal is to convert the structure to JSON to send, but before, it gives me an error when passing the sales list to the client row

    I hope this is clearer.


    Tuesday, June 27, 2017 11:28 PM
  • Okay well that is what the entire program needs to do. What specifically do you need help with?

    Sam Hobbs

    Wednesday, June 28, 2017 1:36 AM
  • Show the error message, as the problem is/will be obvious.

    Wednesday, June 28, 2017 6:48 AM