I'm new to the .Net world and I'm trying to figure out how inheritance and interfaces work exactly. I am trying to implement a Dictionary<string,string> that keeps all the keys as upper case strings. In F# my first naive stab was
type UpperDictionary1() =
inherit Dictionary<string, string>()
override this.Add (key: string, value : string) =
base.Add(key.ToUpper(), value)
That doesn't work because Dictionary Add is sealed. However dropping the override (and shadowing Add instead?) works:
type UpperDictionary2() =
inherit Dictionary<string, string>()
member this.Add (key: string, value : string) =
base.Add(key.ToUpper(), value)
What is the quickest and most appropriate way to implement a special form of dictionary class?
Also, does this relate to Google's ForwardingSet in Java. Are forwarding sets simply an easier way to add this type of functionality or am I missing the point completely?