Basically, you should implement ICollection<T>, but here is a more detailed explanation: http://blogs.msdn.com/madst/archive/2006/10/10/What-is-a-collection_3F00_.aspx.
In the article Mads Torgersen explains that a pattern based approach is used, so the only requirements is that you need to have a public Add method with the correct parameters and implement IEnumerable. In other words, this code is valid and works:
using System.Collections;
using System.Collections.Generic;
class Test
{
static void Main()
{
var dictionary = new HybridDictionary<string, string>
{
{"key", "value"},
{"key2", "value2"}
};
}
}
public class HybridDictionary<TKey, TValue> : IEnumerable<KeyValuePair<TKey, TValue>>
{
private readonly Dictionary<TKey, TValue> inner = new Dictionary<TKey, TValue>();
public void Add(TKey key, TValue value)
{
inner.Add(key, value);
}
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
{
return inner.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}