How to save a List<string> on Settings.Default?

No problem at all! Create a new setting, e.g. "MyListOfStrings", type doesn't matter.

enter image description here

then open settings file in a xml editor

enter image description here enter image description here

your file will look like this:

enter image description here

now change it as shown below and save it

enter image description here

well, that's all, now it will look like that:

enter image description here

and in code:

enter image description here


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.

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

Tags:

C#

.Net

Winforms