Beispiel #1
0
            /// <summary>
            /// Enumerate all the values associated with key.
            /// </summary>
            /// <returns>An IEnumerator&lt;TValue&gt; that enumerates all the values associated with key.</returns>
            public override IEnumerator <TValue> GetEnumerator()
            {
                IEnumerator <TValue> values;

                if (myDictionary.TryEnumerateValuesForKey(key, out values))
                {
                    return(values);
                }
                else
                {
                    return(NoValues());
                }
            }
Beispiel #2
0
 public override IEnumerator <KeyValuePair <TKey, TValue> > GetEnumerator()
 {
     using (IEnumerator <TKey> enumKeys = myDictionary.EnumerateKeys())
     {
         while (enumKeys.MoveNext())
         {
             TKey key = enumKeys.Current;
             IEnumerator <TValue> enumValues;
             if (myDictionary.TryEnumerateValuesForKey(key, out enumValues))
             {
                 using (enumValues)
                 {
                     while (enumValues.MoveNext())
                     {
                         yield return(new KeyValuePair <TKey, TValue>(key, enumValues.Current));
                     }
                 }
             }
         }
     }
 }