У меня есть (или хотел иметь) какой -то код, подобный следующему: < /p>
IDictionary dict = new Dictionary();
// ... Add some stuff to the dictionary.
// Try to find an entry by value (if multiple, don't care which one).
var entry = dict.FirstOrDefault(e => e.Value == 1);
if ( entry != null ) {
// ^^^ above gives a compile error:
// Operator '!=' cannot be applied to operands of type 'System.Collections.Generic.KeyValuePair' and ''
}
< /code>
Я также пытался изменить линию оскорбления, как это: < /p>
if ( entry != default(KeyValuePair) )
< /code>
Но это также дает ошибку компиляции: < /p>
Operator '!=' cannot be applied to operands of type 'System.Collections.Generic.KeyValuePair' and 'System.Collections.Generic.KeyValuePair'
< /code>
Что дает здесь?
Подробнее здесь: https://stackoverflow.com/questions/542 ... -was-found