如何保存列表<串GT;在Settings.Default? [英] How to save a List<string> on Settings.Default?

查看:138
本文介绍了如何保存列表<串GT;在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

推荐答案

我发现我不能直接保存列表<串> 应用程序设置,但我看到了,我可以节省 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.

我发现,这是很简单的从<$ C $转换C> StringCollection 到列表与LT;串&GT;

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();

这篇关于如何保存列表&LT;串GT;在Settings.Default?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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