我有一個ArrayList我想添加它裏面的項目然後分配它bookingrquest.Reservations
我嘗試了幾次,但我沒有得到它的解決方案,如何轉換的ArrayList到BookReservationRQReservation []不能隱式地將類型'System.Collections.ArrayList'轉換爲'BookReservationRQReservation []
BookReservationRQ bookingrquest = new BookReservationRQ();
ArrayList reservation = new ArrayList();
int count = 0;
foreach (var item in reservation_details.selectedrooms)
{
reservation.Add(item.IDHotel);
count++;
}
bookingrquest.Reservations = reservation;// i have this error in this line
public BookReservationRQReservation[] Reservations {
get {
return this.reservationsField;
}
set {
this.reservationsField = value;
}
}
嗯,似乎你將'bookingrquest.Reservations'定義爲'BookReservationRQReservation'的_array_,並不是與包含IDHotel項目的_arraylist_相同。你如何嘗試創建一個'BookReservationRQReservation'數組? – oerkelens
「IDHotel」是什麼類型的?這是一個'BookReservationRQReservation'嗎? –
@RenéVogtIDHotel is stirng這不是他的問題問題是'bookingrquest.Reservations =預訂;' – hashim