运营商&= 39; ==&#39;不能应用于&#39; string&#39;类型的操作数和&#39; System.Collections.Generic.List <string>&#39;

时间:2018-04-16 12:26:57

标签: c# asp.net

根据给定的行列表

帮助我从词典中获取项目
List<string> conversionTypeNames = Conversion1List
  .Select(k => k.ConversionTypeName)
  .Distinct()
  .ToList();

var query = new GoogleAdWordsData_Dictionaries_Query();
var ConversionsDict = query.GetConversionDictionary(ClientID);

ConversionsDict = ConversionsDict
  .Where(k => k.ConversionTypeName == conversionTypeNames);

3 个答案:

答案 0 :(得分:0)

所以我想你想做的是检查转换类型名称中是否存在k.ConversionTypeName,使用此语法


    ConversionsDict = ConversionsDict.Where(k => conversionTypeNames.Contains(k.ConversionTypeName));

答案 1 :(得分:-1)

我找到了正确的解决方案!

var new_Dict = ConversionsDict.Where(p => p.ConversionTypeName != null && !Conversion1List.Exists(a => a.ConversionTypeName == p.ConversionTypeName)).Distinct().ToList();

答案 2 :(得分:-1)

在这里创建一个列表。

List<string> conversionTypeNames = Conversion1List
  .Select(k => k.ConversionTypeName)
  .Distinct()
  .ToList();

请尝试按照代码提取列表

foreach (var s in conversionTypeNames)
{
      ConversionsDict = ConversionsDict
     .Where(k => k.ConversionTypeName == s);    
}