17

我修改了我的 Settings.settings 文件,system_Filters使其成为System.String[].
我想在 Visual Studio 设计器中而不是在代码中填充这个变量。我可以使用以下代码使其在代码中工作:

Properties.Settings.Default.system_Filters = new string[] { "a", "b", "c" };
string _systemFilters = Properties.Settings.Default.system_Filters;

这可以正常工作。但是,我没有一个地方可以将它放入我的代码中,理想情况下希望在 Settings.setting 文件中输入它。该值不会被修改。我已经尝试了几乎所有我能想到的变体,但结果总是一样的。

无法转换为 System.String

有谁知道正确的语法?StringCollection如果这更容易,我也愿意使用。

4

1 回答 1

30

Try to use StringCollection instead of string[]. It is natively supported by the settings designer.

The value is stored as XML, but you don't need to edit it manually. When you select StringCollection in the Type column, the editor in the Value column changes; there is a ... button, which opens a dialog to type the strings.

enter image description here

于 2013-11-21T19:50:10.777 回答