Can you save a common dictionary in Properties.Settings in 4.0?

The new Dictionary<Tkey,TValue> in.net 4.0 is serializable, so ... can I somehow use it in Settings.Settings or Settings.Designer.cs ?

+4
source share
1 answer

Grade. You can define a non-generic class that inherits from the generic class and then reference it in your settings. For instance:

 namespace MyNamespace { public class MyClassDictionary : System.Collections.Generic.Dictionary<string, MyClass> {} } 

Your namespace may not appear in the list of nodes / namespaces when you select "browse" for your installation type, but you can simply enter the full name of the type (for example, MyNamespace.MyClassDictionary ) in the text box in the box at the bottom of the dialog box. You will need to compile once after defining your custom collection.

+3
source

All Articles