我有一個Web服務調用另一個客戶端Web服務。無法隱式轉換類型的Web服務響應
下面是我用來從中提取預訂詳細信息的代碼。
ResMsg.GetBookingsOperationRequest request = new ResMsg.GetBookingsOperationRequest();
int noofBookings = 3;
DateTime checkInDate;
DateTime checkOutDate;
string bookingStatus;
string Notes;
int adults;
int children;
Int64 bookingID;
string bookingSource;
DateTime bookingDate;
string resResult;
using (var proxy = new ResMesg.ResonlineMsg.InventoryServiceClient())
{
var result = proxy.GetModifiedBookings(request);
ResMsg.Booking[] bookings= new ResMsg.Booking[noofBookings];
result.Bookings = new ResMesg.ResonlineMsg.Booking[noofBookings];
result.Bookings = bookings;
for (int i = 0; i < bookings.Length; i++)
{
Booking bk = new ResMesg.ResonlineMsg.Booking();
result.Bookings[i]=bk;
bookingID = bk.BookingId;
checkInDate = bk.CheckInDate;
checkOutDate = bk.CheckOutDate;
adults = bk.Adult;
children = bk.Children;
bookingStatus = bk.BookingStatus;
Notes = bk.Note;
bookingSource = bk.BookingSource;
bookingDate = bk.BookingDate;
bk.GuestInfo = new GuestDetails[noofBookings]; ** Place where error is referring to.GuestDetails is an array. GuestInfo is an instance of GuestDetails.
}
return "Success";
}
錯誤1無法隱式轉換類型 'ResMesg.ResonlineMsg.GuestDetails []' 到 'ResMesg.ResonlineMsg.GuestDetails'
**更新: 數據類型GuestDetails
Field Data Type Description
Name string Guest's full name.
Address string Guest's address.
EmailAddress string Guest's email address.
PhoneNumber string Guest's phone number.
從對象瀏覽器複製出來的GuestDetails的定義
public GuestDetails GuestInfo { set; get; }
(Member of Booking)
我將不勝感激任何形式的建議如何解決這個錯誤或爲什麼它來。感謝
GuestInfo是GuestDetails的一個實例。你做「GuestInfo = new GuestDetails [noofBookings]」。 –
對不起,我不知道這是否使用了上述正確的上下文,但我從前一個答案我收到前一個例子:http://stackoverflow.com/a/10096691/1270384 – user1270384