Since Array does not have For each is there an alternate way we can use LINQ to do some action

svc_Orders is an array of SVCORDER[]

List<Order> local_order_list  = new List<Order>();

foreach (var svc_Order in svc_Orders)
{
    Order local_Order = new Order();
    //Converting SVCORDER to Order
    local_Order_list.Add(local_Order);
}

Now I am looping through the svc_order returned from the service converting them and Order adding them to list. Is there a better way of doing it?

Jon Skeet
people
quotationmark

If you want to project items from one type to another, that's what Select is for - then there's the ToList method:

// Names changed to conform to .NET conventions
var localOrderList = serviceOrders.Select(serviceOrder => new Order { ... })
                                  .ToList();

(We don't know what goes in the ... as you haven't told us how you'd convert from SVCORDER to Order. You may want to turn that into a method to call from Select...)

people

See more on this question at Stackoverflow