這裏是我的字典數據類型:如果能夠拉含列表<>詞典的值
private Dictionary<String, List<PriceAndStandard>>
PriceAndStandard是一個結構:
struct PriceAndStandard
{
public double mePrice;
public int? meStandard;
}
我希望能夠抓住mePrice和meStandard爲每一個項目。
錯誤我recieving
Type of conditional expression cannot be determined because there is no implicit conversion between 'System.Collections.Generic.List<AspDotNetStorefront.showproduct.PriceAndStandard>
我就能夠抓住的價值,如果它是一個基本的鍵 - 字符串值對:
shaftModelDictionary.Values.ToList();
但因爲我有一個列表我真的需要將數據展平以便可以存儲。
工作代碼:
foreach (string option in product.AvailableClubOptions.ShaftModel)
{
string shaftModelText = option;
if (minPriceForShaftMaterial > 0 && !string.IsNullOrEmpty(option))
{
List<PriceAndStandard> Paul = shaftModelDictionary.Keys.ToList();
double priceForShaftModel = shaftModelDictionary.[option];
double priceForSelectedShaftModel = !String.IsNullOrEmpty(shaftModel) ? shaftModelDictionary[shaftModel] : 0;
更新: 好像有一個與option
一個問題,因爲這是一個字符串,在我的字典裏是列出的值不兼容。
更新2:
foreach (string option in product.AvailableClubOptions.ShaftModel)
{
string shaftModelText = option;
if (minPriceForShaftMaterial > 0 && !string.IsNullOrEmpty(option))
{
double priceForShaftModel = shaftModelDictionary[option].mePrice;
double priceForSelectedShaftModel = !String.IsNullOrEmpty(shaftModel) ? shaftModelDictionary[shaftModel].mePrice : 0m;
double priceDelta = 0.0d;
double MinimumPrice = Convert.ToDouble(ltOurPrice.InnerText.Replace("$", ""));
'列表' 中不包含關於 'mePrice' 和沒有擴展方法的定義 'mePrice' 接受型 '列表'
第一條紅色swigely線下雙價priceForShaftModel = shaftModelDictionary [選項] – user1869407
請參閱我的編輯 - 在最後添加「m」。 – Sam
檢查更新2. mePrice在我的IDE中有一個下劃線的swigley,它們發生在這兩個地方 – user1869407