私はItem
という名前のクラスを持っていて、それはAirpricepoint
のリストを保持しています。私は、クラスのすべてのプロパティを作成して初期化し、Airpricepoint
リストを追加することができます。 Airpricepoint
クラスには、いくつかのプロパティを持つ別のリストAirPricingInfo
があります。 AirPricingInfo
のメンバーにアクセスして初期化し、リストに追加するにはどうすればよいですか?リストコレクション内のリストを初期化する方法
public class Item
{
public List<Airpricepoint> AirPricePoint { get; set; }
}
public class Airpricepoint
{
public List<Airpricinginfo> AirPricingInfo { get; set; }
public string AirPricingResultMessage { get; set; }
public string FeeInfo { get; set; }
public string FareNote { get; set; }
public string TaxInfo { get; set; }
public string Key { get; set; }
public string TotalPrice { get; set; }
public string BasePrice { get; set; }
public string ApproximateTotalPrice { get; set; }
public string ApproximateBasePrice { get; set; }
public string EquivalentBasePrice { get; set; }
public string Taxes { get; set; }
public string Fees { get; set; }
public string Services { get; set; }
public string ApproximateTaxes { get; set; }
public string ApproximateFees { get; set; }
public string CompleteItinerary { get; set; }
}
public class Airpricinginfo
{
public object FareInfo { get; set; }
public object FareStatus { get; set; }
public IList<FareInfoRef> FareInfoRef { get; set; }
public object BookingInfo { get; set; }
public IList<TaxInfo> TaxInfo { get; set; }
public string FareCalc { get; set; }
}
var lowfaresearchres = new Lowfaresearchres();
lowfaresearchres.Items= new Item();
lowfaresearchres.Items.AirPricePoint = new List<Airpricepoint>();
lowfaresearchres.Items.AirPricePoint.Add(new Airpricepoint()
{
ApproximateBasePrice = airPricePoint.ApproximateBasePrice,
ApproximateTotalPrice = airPricePoint.ApproximateTotalPrice,
ApproximateTaxes = airPricePoint.ApproximateTaxes,
ApproximateFees = airPricePoint.Fees,
BasePrice = airPricePoint.BasePrice,
Taxes = airPricePoint.Taxes,
TotalPrice = airPricePoint.TotalPrice
});
をどのようにあなたは知っていますかリスト内のアイテムにアクセスしますか?そうでない場合は、C#/ .NETの基本的な/基本的なコレクションに関するC#チュートリアルを参照してください。 – elgonzo
'Item'コンストラクタで' List 'をインスタンス化することもできますそこから。 –
maccettura