Just now I came across ApplicationSettings in .NET WinForms that could handle complex types.
Currently I am using AppSettings in my ASP.NET WebForms which can handle onl
Here's a variation on the accepted answer, using the following user-defined class to represent a setting:
namespace MyApplication
{
public class EndPoint
{
public string HostName { get; set; }
public int Port { get; set; }
}
}
The accepted answer proposes the use of a specialised collection class, EndPointCollection
to hold settings. However, I don't think this is necessary; an array type (EndPoint[]
) also seems to work.
However, typing the array type in the type browser doesn't work; you can instead specify the type directly in the .settings file (using a text editor):
Also, if the value editor shown in the accepted answer isn't available, you can instead type the values directly into the value field using XML:
MyHostName
12345
MyHost1
1212
Note that the XML namespace declarations that Visual Studio generates aren't necessary in the XML, as shown above.