I’m getting a weird error when doing this: (.net 2.0)
public overrides List<String> getSpaceballs
{
get { return new List<String>() { "abc","def","egh" }; }
}
VS is asking for ; after (). Why?
I sure can do this:
public overrides string[] getSpaceballs
{
get { return new string[] { "abc","def","egh" }; }
}
The first option is not legal 🙂
You can only do that type of initialiser on arrays.
— Edit: See Andrew Hare’s post (and others, below); it is only available in v3 and up.
— Edit again:
Just to be clear, if your compiler is of 3 or greater, you can target 2.0, to get this to work (because it’s compiled down to the code that Andrew shows, below). But if your compiler is 2, then you can’t.