C # Way to serialize List <string> in settings containing any character (Regex / xml)

I am looking for a neat / clean way to store a list of strings in a C # settings file . As far as I can do this, you cannot store List objects in these settings, so basically it needs to be converted to a string. For example, let's say I have a list of names:

  • NAMEA
  • Name, B
  • Complex, weird, name
  • Name "nickname" Man

i.e. I am trying to demonstrate a list of names that may contain any character . Anyone have recommendations on neat + Regex forms to read them that any character can handle? Or perhaps an easy way to serialize List<string>?

Currently, I save them as a simple command-delimited string, which works fine as long as you are careful with the names (cannot have commas), but is destined to split the string.

+3
source share
1 answer

You can select the type of recording settings as

System.Collections.Specialized.StringCollection

on the Properties.Settings tab.

This will be translated into your configuration file, sort of like

 <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <string>string1</string>
  <string>string2</string>
 </ArrayOfString>
+7
source

Source: https://habr.com/ru/post/1722318/


All Articles