It is possible to create an array at compile time like;
int[] myValues = new int[] { 1, 2, 3 } ;
But I would like to do something like this;
List<int> myValues = new List<int>() { 1, 2, 3 };
The compiler says No. Is there a way to do this (C# 2.0) without using LINQ (C# 3.0)?
This will create an intermediate array however so there may be a more efficient way of doing the same thing.
EDIT:
John Feminella suggested creating a factory method to accept a list of parameters and return a List which you could implement as follows:
which you can use as follows: