开发者

C# - data structure used for settings file

Does C# offer something default to store application / any sort of settings?

I could use Dictionary<K, T>, but actually I would prefer some structure, which natively supports xml export / import and different other features, which aren't implemented in the Dictionary or other map-like collections.

For example, in C++ I would use QSettings in Qt or something like boost::property_tree if using boost.

If you have any ideas or good implementations, that woul开发者_运维问答d be great. Thank you.


You want System.Configuration.ConfigurationManager, especially ConfigurationManager.AppSettings, which is a System.Collections.Specialized.NameValueCollection.


AppSettings sounds like it fits the bill:

http://odetocode.com/code/345.aspx


Yes, I think this is what you are looking for: http://msdn.microsoft.com/en-us/library/k4s6c3a0.aspx

Example of how it's used herE: http://msdn.microsoft.com/en-us/library/aa730869%28v=vs.80%29.aspx


If Properties.Settings doesn't work for you, then you might just create your own class hierarchy of settings, and use simple XML serialization/deserialization to handle the file I/O. I find this much more flexible than .NET settings.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜