gpt4 book ai didi

c# - 为什么会出现这个异常?

转载 作者:太空宇宙 更新时间:2023-11-03 19:22:06 26 4
gpt4 key购买 nike

我在 c# 中有一个 dictionary 名称 Pair。它包含一些键值对。我添加了一个屏幕截图,在 (p.Key == "left) 上生成了一个异常,Sequence containes no matching element 但是如果你在 中看到Pair Dictionaryleft 键出现在那里。那么谁能告诉我为什么会出现这个异常?

最佳答案

如果我没看错的话,left 值前面有一个空格,"left",所以 p.Key == "left" 永远不会为真。

改用 p.Key.contains("left"),或者在尝试操作它之前检查它是否返回值。或者修剪前导和尾随空格。

关于c# - 为什么会出现这个异常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11483623/

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