简体   繁体   中英

Display all elements in array from a response

Ok I have a confusing question (I think) in regards to request and response values.

I created a request to search for Customers within a database based on the company name. Here is the code:

//Search through customers
        public void ArrangeRequest()
        {
            _request = new CustomerSearchRequest();                  
            _request.Company = "NewCustomers Inc";
        }

Here is customer info before it is requested and given values:

//Customer Info
        _request.Customer = new CustomerInfo
        {       
            Company = "NewCustomers Inc. ",
            CustStatus = Status,
            CustID = custid, 
            Fax = "(855) 555-6956",
            Phone = "(568) 895-6954",
            ProviderId = 56958,
            TechContact = _techcontact,
            TimeZoneInfoID = "Central Standard Time",
        };

This request works and when I debug I get the message that 52 customers were found. Now, each of those customers has a unique customer ID that was created when they were. When I debug I am able to see all the information for the customers including their customer ID. My problem is I am trying to output all those values to a text file. The problem is the customer ID's are in an array with all the other information in: CustomerInfo[] . Now I am able to output each individual value in the array by saying CustomerInfo[1] or CustomerInfo[2], but I want to be able to make the search and output all the values in the array without having to call each individual value.

I want this so that if I wanted to search for another company and it has 1000 results then I won't have to call each one obviously.

edited based on OPs comments:

foreach(var customer in _response.Customers)
{
    Console.WriteLine(customer.CustID);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM