I have a scenario where I have a custom mapping class.
I would like to be able to create the new instance and declare data for it at the same time and implement a syntax similar to:
public static HybridDictionary Names = new HybridDictionary()
{
{People.Dave, "Dave H."},
{People.Wendy, "Wendy R."}
}
and so on. How do I define my class to enable this kind of syntax?
What you are trying to acheive is a Collection Initializer
Your HybridDictionary class need to implement IEnumerable<> and have an Add method like this:
Then your instanciation should work.
Note: By convention, the key should be the first parameter followed by the value (i.e. void Add(string key, People value).