我想将一维字符串数组存储为我的 appSettings
中的条目。我不能简单地用 、
或 |
分隔元素,因为元素本身可能包含这些字符。
我正在考虑将数组存储为 JSON
,然后使用 JavaScriptSerializer
对其进行反序列化。
是否有“正确”/更好的方法来做到这一点?
(我的 JSON
想法感觉有点老套)
最佳答案
您可以将 AppSettings 与 System.Collections.Specialized.StringCollection
一起使用.
var myStringCollection = Properties.Settings.Default.MyCollection;
foreach (String value in myStringCollection)
{
// do something
}
每个值都用换行符分隔。
这是一个屏幕截图(德语 IDE,但无论如何它可能会有所帮助)
关于asp.net - 将字符串数组存储在 appSettings 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10419116/