我有以下课程
namespace TaxiResults.Model
{
public class SearchResult
{
public string status { get; set; }
public SearchResultResult result { get; set; }
}
public class SearchResultResult
{
public SearchResultOffer offer { get; set; }
}
public class SearchResultOffer
{
public SearchResultOffer1[] offers { get; set; }
}
public class SearchResultOffer1
{
public SearchResultAddress[] addresses { get; set; }
public string chnl { get; set; }
public string companyInfoId { get; set; }
public string companyName { get; set; }
public string bookingId { get; set; }
public string tz { get; set; }
public string pickupDateTime { get; set; }
public string pickupDateTimeUTC { get; set; }
public int routeDuration { get; set; }
public int routeDistance { get; set; }
public SearchResultPricedetail priceDetail { get; set; }
public float tax { get; set; }
public string services { get; set; }
public int bagCount { get; set; }
public int passengerCount { get; set; }
public int productType { get; set; }
public string resultset { get; set; }
public string companyInfoId3cd { get; set; }
}
public class SearchResultPricedetail
{
public SearchResultOriginalprice originalPrice { get; set; }
public SearchResultFinalprice finalPrice { get; set; }
}
public class SearchResultOriginalprice
{
public SearchResultAmount[] amounts { get; set; }
}
public class SearchResultAmount
{
public string currency { get; set; }
public string priceExcludingTax { get; set; }
public float priceExcludingTaxNumber { get; set; }
public string priceTotal { get; set; }
public float priceTotalNumber { get; set; }
public float exchangeRate { get; set; }
public string priceTax { get; set; }
public float priceTaxNumber { get; set; }
}
public class SearchResultFinalprice
{
public SearchResultAmount1[] amounts { get; set; }
}
public class SearchResultAmount1
{
public string currency { get; set; }
public string priceExcludingTax { get; set; }
public float priceExcludingTaxNumber { get; set; }
public double priceTotal { get; set; }
public float priceTotalNumber { get; set; }
public float exchangeRate { get; set; }
public string priceTax { get; set; }
public float priceTaxNumber { get; set; }
}
public class SearchResultAddress
{
public SearchResultLocation location { get; set; }
public string address { get; set; }
public int type { get; set; }
}
public class SearchResultLocation
{
public float lat { get; set; }
public float lng { get; set; }
}
}
我想做一个 foreach 循环,Taxi.Model.SearchResult
将它输入到我在 MVC 视图中返回的模型中。
但我得到了错误:
foreach 语句无法对“Taxi.Model.SearchResult”类型的变量进行操作,因为“Taxi.Model.SearchResult”不包含“GetEnumerator”的公共定义
我是 c#.net 的新手,谁能告诉我我需要做什么才能让我做一个 foreach 吗?
谢谢