Hello, There Service07.Eso9PortClient class that contains method getOrders () which returns an array of orders. Each order contains information (address, folders, etc.). I need to convert these orders into an array or collection so that I could browse and handle these orders. Could someone advise me how to do it? / / Order to convert the array or collection / / / / Orders Service07.Eso9PortClient orderClient07 Service07.Eso9PortClient = new (); Service07.Order [] orders = orderClient07.getOrders (); foreach (Service07.Order order in orders) { / / Order addresses Service07.Address [] addresses = order.Addresses; foreach (Service07.Address address in addresses) { / / Addresses attributes Service07.Attribute [] = addressAttributes address.Attributes; foreach (Service07.Attribute addressAttribute in addressAttributes) { string = addressAttributeName addressAttribute.Name; string = addressAttributeValue addressAttribute.Value; } string = addressCity address.City; string = addressCompany address.Company; string = addressCountry address.Country; } / / Order attributes Service07.Attribute [] = orderAttributes order.Attributes; foreach (Service07.Attribute orderAttribute in orderAttributes) { string = orderAttributeName orderAttribute.Name; string = orderAttributeValue orderAttribute.Value; } / / Order Coupon string = orderCouponCode order.Coupon! = null? order.Coupon.Code: null; string = orderCuponValue order.Coupon! = null? order.Coupon.Value: null; / / Order Created string = orderCreated order.Created; / / Order items Service07.OrderItem [] items = order.Items; foreach (Service07.OrderItem item in items) { string itemName = item.Name; string = itemNote item.Note; } } // Result should look something like this string ... myArray = new ... foreach (string in order myArray) { foreach (string address in myArray...) { .... } } Unfortunately I do not know how to declare a field and set :-( Thank you for your answer
lada_vyvojar
Posts
-
Creating a multidimensional array from class -
C# Working with C # classes from different namespacesHello, There namespace Company.Service01, which contains classes and interfaces. There namespace Company.Service02, which contains classes and interfaces. Both spaces have the same structure of, contain the same classes and interfaces. I need to somehow ensure that I could work with class (for example: Eso9PortClient) from this namespace, depending on the input parameters of the program. It's possible there is some technique to it? The goal is that I did not have to repeat the same code n times the number of namespaces. Example: file01.cs namespace Company.Service0X { public interface Eso9Port {...} public partial class FaultInfo {...} public interface Eso9PortChannel {...} public partial class Eso9PortClient {...} } file02.cs namespace Company { class Program { static void Main (string [] args) { if (args [0] == "01") { MultiService MultiService m = new (); m.CreateOrder (); } else if (args [0] == "02") { MultiService MultiService m = new (); m.CreateOrder (); } else if (args [0] == "03") { MultiService MultiService m = new (); m.CreateOrder (); } } } public class MultiService { public void CreateOrder () { // Work with the instance Company.Service0X.Eso9PortClient // depending on the parameter in class Program Company.Service0X.Eso9PortClient Company.Service0X.Eso9PortClient x = new (); string xx = x.orders ... } } } Thank you in advance for your reply