Dictionary: обращение по ключу и по индексу - C#
Формулировка задачи:
Помогите исправить, необходимо написать класс к элементам которого можно обращаться по ключу и индексу
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Collections.Specialized;
namespace it_3_zadanie
{
class Program
{
public class OrderedDictionarySample
{
static void Main(string[] args)
{
OrderedDictionary myOrderedDictionary = new OrderedDictionary();
Dictionary<string, string>
st = new Dictionary<string, string>();
st.Add("admin", "Opel");
st.Add("Radmin", "Mazda");
st["Sadmin"] = "BMW";
st.Remove("admin");
st.Remove("Sadmin");
foreach (KeyValuePair<string, string> kp in st)
{
Console.WriteLine(kp.Key + "\t" + kp.Value);
Console.ReadKey();
}
}
}
}
}Решение задачи: «Dictionary: обращение по ключу и по индексу»
textual
Листинг программы
class MyClass:Dictionary<string,object>
{
public object GetByKey(string key)
{
return this[key];
}
public object GetByIndex(int index)
{
return this.ElementAt(index);
}
}