【问题标题】:how to filter data from from a dictionary to list如何从字典中过滤数据到列表
【发布时间】:2017-03-31 09:29:29
【问题描述】:
Dictionary<string, int> d4 = (Dictionary<string,int>)Session["Barcodes"];

字典包含条形码。同时,

List<AddInventory> Getdetails = Deserialize<List<AddInventory>>(Session[hdnPullId.Value].ToString());

这包含一个列表。在此模型 AddInventory 中,有一个属性 Barcode,而在 dictionary 中,字符串包含 BarcodeList 有很多冗余条目,所以我只想在我的List 中包含这些条目,它们存在于dictionary 中。

我们将不胜感激。

谢谢

【问题讨论】:

    标签: c# linq dictionary


    【解决方案1】:

    我只想在我的列表中包含这些条目,它们存在于 字典。

    Getdetails = Getdetails.Where(i => d4.ContainsKey(i.BarCode)).ToList();
    

    如果您想删除多余的条目,您需要告诉我们您要保留哪些条目。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-08
      • 2022-12-02
      • 2018-04-30
      • 2022-01-25
      • 1970-01-01
      • 1970-01-01
      • 2022-01-23
      • 2020-04-30
      相关资源
      最近更新 更多