On Aug 9, 4:35 pm, "jeffc" <nos...@nospam.comwrote:
I have the following declaration, and I want to initialize the list at the
same time. Is there a way?
private static List<StringFILE_LIST = new List<String>();
Not in C# 1 or 2 :(
Actually, that's not quite true... it's ugly as heck, but this works:
static readonly List<stringFileList = new List<string>
(new string[] {"First file", "Second file"});
In C# 3 you can use collection initializers:
static readonly List<stringFileList = new List<string>
{
"First file"
"Second file"
};
Much nicer :)
Jon