Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何从列表中删除条目<;KeyValuePair<;字符串,字符串>&燃气轮机;仅仅基于钥匙?_C#_.net_Collections - Fatal编程技术网

C# 如何从列表中删除条目<;KeyValuePair<;字符串,字符串>&燃气轮机;仅仅基于钥匙?

C# 如何从列表中删除条目<;KeyValuePair<;字符串,字符串>&燃气轮机;仅仅基于钥匙?,c#,.net,collections,C#,.net,Collections,我有一个KeyValuerPair myList。如何根据密钥删除条目?我应该如何使用myList.Remove方法?我没有使用字典,因为我需要myList作为Bindingsource的数据源 List<KeyValuePair<string, string>> myList = new List<KeyValuePair<string, string>>(); string key = "@index"; 谢谢你, VRP。使用。可以传入检

我有一个KeyValuerPair myList。如何根据密钥删除条目?我应该如何使用myList.Remove方法?我没有使用字典,因为我需要myList作为Bindingsource的数据源

List<KeyValuePair<string, string>> myList = new List<KeyValuePair<string, string>>();

string key = "@index";
谢谢你, VRP。

使用。可以传入检查键值的谓词。 例如:


这很有效,非常感谢你的改善。如果我没有弄错的话,谓词是否作为委托,只是它只返回布尔值?
myList.Remove( i am lost here )
myList.RemoveAll(kvp => kvp.Key == "@index");