Esempio n. 1
0
        static void Main(string[] args)
        {
            var myDictionay = new DictionaryWhithCustomKey <int, string, int>
            {
                { new MyKey()
                  {
                      Id = 1, Name = "Вася"
                  }, 23 },
                { new MyKey()
                  {
                      Id = 1, Name = "Петя"
                  }, 23 },
                { new MyKey()
                  {
                      Id = 2, Name = "Коля"
                  }, 30 },
                { new MyKey()
                  {
                      Id = 3, Name = "Саша"
                  }, 33 },
                { new MyKey()
                  {
                      Id = 4, Name = "Женя"
                  }, 35 }
            };

            foreach (var item in myDictionay)
            {
                Console.WriteLine($"Id:{item.Key.Id} Имя:{item.Key.Name} Возраст:{item.Value}");
            }
            Console.WriteLine(new string('-', 20));
            var users = myDictionay[1];

            foreach (var user in users)
            {
                Console.WriteLine($"Id:{user.Key.Id} Имя {user.Key.Name} Возраст {user.Value}");
            }
            Console.ReadKey();
        }
            public DictionaryWhithCustomKeyEnumerator(DictionaryWhithCustomKey <TId1, TName1, TValue1> dictionary)

            {
                this.values = dictionary.values;
            }