I'm choosing between two implementations for a lookup (readonly) list of strings.
With getter:
public static List<string> MyList { get { return myList; } }
private static readonly List<string> myList = new List<string>
{
"Item 1", "Item 2", "Item 3"
};
Or simply:
public static readonly List<string> MyList = new List<string>
{
"Item 1", "Item 2", "Item 3"
};
I would go for the second one for simplicity, but just reading from the code it looks like the second implementation will create a new List every time, whereas in the first implementation there's no such recurring overhead.
Is that the right way to think about it? Or are there better implementations for what I am trying to achieve?
Thanks!