-1
그래서 나는 호텔 정보와 함께 필요한 배열을 하나씩 가지고 있는데, 각 호텔의 위치가 필요하다면 다른 방법으로 보낼 수 있습니다. 그래서 저는 첫 번째 foreach 설정을했습니다. 그러나 이제 모든 위치 정보를 문자열 배열로 수집하여 모든 호텔을 읽은 후에 보낼 수 있는지 궁금합니다. 누군가 도울 수 있습니까, 고마워요.C에서 문자열 배열에 중첩 된 foreach
// API call to get the info
ContentAPI.BasicHotelMedia[] rawData = DataHelper.NewContentAPI().GetBasicHotelMedia(ProductCode, ProductYear, SiteBrand);
//setting up the datatable
DataTable dtHotels = InitHotelTable();
//set my variables
foreach (ContentAPI.BasicHotelMedia item in rawData)
{
DataRow dr = dtHotels.NewRow();
dr["HotelCode"] = item.BasicHotelCode;
dr["HotelDescription"] = item.BasicDescription;
dr["WiFi"] = item.HasWifi;
// This is the variable that i need set in the string array so i can send into another method
dr["SellingLocation"] = item.BasicSellingLocation;
// Add other raw data
// Get other info about the hotel
GetHotelMedia(item.BasicHotelCode, ProductYear, item.HasWifi, ref dr);
dtHotels.Rows.Add(dr.ItemArray);
}
문자열 배열을 선언하고 문제의 행에 추가하려고 했습니까? 매우 간단합니다. –
그래서 당신은 단지 dr [ "SellingLocation"] 대신 문자열 배열로 설정한다고 말하고 있습니까? – user1566783
왜 문자열로 필요합니까 []? 그것은 하나의 기록이 아닌가? – Ehsan