如何保存列表<字符串>在设置.默认? [英] How to save a List<string> on Settings.Default?
本文介绍了如何保存列表<字符串>在设置.默认?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的表单上有一个 ListBox,我想保存它并在我再次启动应用程序时加载值.
I have a ListBox on my Form, I want to save it and load the values when I start the application again.
如何在 PrjName.Properties.Settings.Default
上保存列表?
How can I save a list on PrjName.Properties.Settings.Default
?
推荐答案
我发现我不能直接在应用程序设置上保存一个List
,但我看到我可以保存一个 StringCollection
.
I found out that I can't directly save a List<string>
on the application settings, but I saw that I can save a StringCollection
.
和 此处 我发现从 StringCollection 转换非常简单
到 List
And here I found out that it's very simple to convert from a StringCollection
to a List<string>
var list = stringCollection.Cast<string>().ToList();
这篇关于如何保存列表<字符串>在设置.默认?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文