Dictionary with single item
Posted
by alhazen
on Stack Overflow
See other posts from Stack Overflow
or by alhazen
Published on 2010-05-02T20:18:48Z
Indexed on
2010/05/02
20:28 UTC
Read the original article
Hit count: 255
In the case where Dictionary<object, object>
myDictionary
happens to contain a single item, what is the best way to retrieve the value object (if I don't care about the key) ?
if (myDictionary.Count == 1)
{
// Doesn't work
object obj = myDictionary.Values[0];
}
Thanks
© Stack Overflow or respective owner