gpt4 book ai didi

c# - 方法包含在文本列表字符串类型的字典中

转载 作者:太空宇宙 更新时间:2023-11-03 14:47:53 24 4
gpt4 key购买 nike

我有一本字典,其中的键类型为 TextList<string> 类型的值我想测试这个字典是否包含名称为“U.R.P.S. PROVISIONNELLE”的键。

我所做的是:

Dictionary<Text, List<string>> echancierURSSAFE = new Dictionary<Text, List<string>>();

var dictionaryPROVIS = new Dictionary<string, string>();

dictionaryPROVIS.Keys.Where(key => echancierURSSAFE.Contains("U.R.P.S. PROVISIONNELLE")).ToList();

这里是 Text类:

public class Text
{
public String Titre { get; set; }
public bool IsTitre { get; set; }

public bool IsDesignation { get; set; }
}

这里我有一个异常(exception),这种类型的字典不包含方法 contains .那么我该如何解决这个问题呢?

最佳答案

根据您的评论,您可以尝试将 AnyTitre 一起使用,这将检查 Dictionary 文本的 Titre 包含任何 "U.R.P.S. PROVISIONNELLE"

echancierURSSAFE.Keys.Any(x => x.Titre == "U.R.P.S. PROVISIONNELLE");

如果你想得到所有的列表你可以使用Where

echancierURSSAFE.Keys.Where(x => x.Titre == "U.R.P.S. PROVISIONNELLE");

关于c# - 方法包含在文本列表字符串类型的字典中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53302759/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com