List 能够提取包含列表的字典值<&燃气轮机;
以下是我的字典数据类型:List 能够提取包含列表的字典值<&燃气轮机;,list,dictionary,List,Dictionary,以下是我的字典数据类型: private Dictionary<String, List<PriceAndStandard>> 我想能够抓住每一个项目的mePrice和Messtandard 我收到一个错误 Type of conditional expression cannot be determined because there is no implicit conversion between 'System.Collections.Generic.List&
private Dictionary<String, List<PriceAndStandard>>
我想能够抓住每一个项目的mePrice和Messtandard
我收到一个错误
Type of conditional expression cannot be determined because there is no implicit conversion between 'System.Collections.Generic.List<AspDotNetStorefront.showproduct.PriceAndStandard>
但因为我有一个列表,所以我真的需要将数据展平,以便可以存储
工作代码:
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;
“List”不包含“mePrice”的定义,并且没有扩展方法“mePrice”接受类型为“List”的第一个参数
double priceForSelectedShaftModel = !String.IsNullOrEmpty(shaftModel) ? shaftModelDictionary[shaftModel].first().mePrice : 0d;
编辑:
我的第一个回答不正确,对不起。字典中的值是列表。因此,当您检索一个值(即PriceAndStandard对象的列表)时,您需要使用该列表,或者在列表中查找要使用的特定PriceAndStandard对象。在我展示的示例中,我使用first()方法查找列表中的第一个对象。您可能希望了解LINQ并使用where()方法或类似的方法
我不确定你想要完成什么。。。是否确实要将dict中的值设置为列表?这没什么错,只是有点不寻常。也许你在想这个
private Dictionary<String, PriceAndStandard>
专用字典
0m也是十进制的,0d是双精度的。我的错。第一条红色swigely线的价格是双倍的,用于ShaftModel=shaftModelDictionary[选项]检查更新2。mePrice在我的IDE中的两个地方都有一个带下划线的swigley,它们在这两个地方都占据了银行的位置,以便后续跟进。我想我只是在装傻。我根本不应该使用列表!价格和标准可能是解决之道。如果不是,我会告诉你的。太复杂了。你的代码在工作吗?如果我帮了你,请记下我的答案。谢谢。
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("$", ""));
double priceForSelectedShaftModel = !String.IsNullOrEmpty(shaftModel) ? shaftModelDictionary[shaftModel].first().mePrice : 0d;
private Dictionary<String, PriceAndStandard>