无法将HashTable,对象...保存为应用程序设置? [英] Can't save HashTable, object ... as app settings?

查看:87
本文介绍了无法将HashTable,对象...保存为应用程序设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将哈希表另存为应用程序设置?
我可以将一个字符串(一个StringCollection)保存为应用程序设置,但不能对许多其他类型(例如HashTable,object)执行相同的操作.我这样编码:
Settings.Default.Users =新的HashTable();
Settings.Default.Users.Add(用户名,密码);
Settings.Default.Save();
它应该保存一对键和值,但事实并非如此.
每次应用启动时,Settings.Default.Users都会为null.
您能告诉我如何保存吗?请不要引导我使用任何不使用HashTable来保存键和值对的解决方案.我只想使用HashTable.
非常感谢!

Could you please let me know if saving a hashtable as app setting is possible?
I can save a string, a StringCollection as app settings but can''t do the same to many other types such as HashTable, object. I coded like this:
Settings.Default.Users = new HashTable();
Settings.Default.Users.Add(username, password);
Settings.Default.Save();
It should save the pair of key and value but it doesn''t.
Each time the app starts that Settings.Default.Users becomes null.
Could you please show me how to save it? Please don''t lead me to any solution for saving a pair of key and value without using HashTable. I want to use HashTable only.
Thank you very much!

推荐答案

哈希表是名称/值对的集合.

也许这会有所帮助
了解节处理程序-App.config文件 [如何:使用ConfigurationSection创建自定义配置节 [
A Hashtable is a collection of name/value pairs.

Perhaps this will help
Understanding Section Handlers - App.config File[^]
How to: Create Custom Configuration Sections Using ConfigurationSection[^]


您可以使用以下序列化程序可以理解像我的 fastJSON 之类的哈希表,并将输出保存在您的应用程序设置中.
You can use a serializer that understands hashtables like my fastJSON and save the output in your app settings.


这篇关于无法将HashTable,对象...保存为应用程序设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆