Skip to content

Instantly share code, notes, and snippets.

@vertigra
Last active February 3, 2017 05:59
Show Gist options
  • Save vertigra/dcabe5c6c72e3e80431d278ce6650a74 to your computer and use it in GitHub Desktop.
Save vertigra/dcabe5c6c72e3e80431d278ce6650a74 to your computer and use it in GitHub Desktop.
Использование StringCollection в Settings

Использование StringCollection в Settings

В properties проекта на вкладке Setting в поле Name пишем имя переменной.
В поле Type System.Collections.Specialized.StringCollection.
Поле Scope - по необходимости (User/Application).

Важно
В поле value необходимо ввести и удалить значение c помощью кнопки ...

SaveStringCollection

Иначе при добавлении значения в массив (например Settings.Default.ExampleName_Collection.Add(StringValue)) будет ошибка:

An unhandled exception of type 'System.NullReferenceException' occurred in ExampleAddStringCollection.exe

Additional information: Ссылка на объект не указывает на экземпляр объекта.

Взято тут. Точно работает на VS2015.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment