
I have a dictionary name Pair in c#. It contains some key – value pairs. I added a screen shot, there was an exception generated on (p.Key == "left), Sequence containes no matching element but if you see in the Pair Dictionary, the left key is present there. Then please anybody tell me why this exception occured ?
If I can see it right, the
leftvalue is preceded with a whitespace," left", sop.Key == "left"is never true.Use
p.Key.contains("left")instead, or check if it returns a value or not, before trying to manipulate it. Or trim the leading and trailing whitespaces.