Пример #1
0
 public static IEnumerable <Value> Select <Key, Value>(this KeyedCollection <Key, Value> keyedCollection, IEnumerable <Key> keys)
     where Key : notnull
     where Value : notnull
 {
     foreach (Key key in keys)
     {
         if (keyedCollection.Peek(key, out Value value))
         {
             yield return(value);
         }
     }
 }
Пример #2
0
        public static bool CastedPeek <Key, Value, Result>(this KeyedCollection <Key, Value> keyedCollection, Key key, out Result result)
            where Key : notnull
            where Value : notnull
            where Result : notnull, Value
        {
            if (keyedCollection.Peek(key, out Value value) && value is Result match)
            {
                result = match;
                return(true);
            }

            result = default !;