So, I am designing a global constant which would hold data for different characters for the program. I think System.Collections.Generic.Dictionary
is my data type here, as it allows very quick searches by character. The declaration looks like this:
public static readonly Dictionary<char, LetterImage> letters;
(LetterImage
being a custom struct. It's contents are not important.)
The problem? How do I define the elements of the Dictionary
? I cannot just letters.Add('a', new LetterImage{...})
because the dictionary is readonly
, as I don't want a global variable. I need a way to initialize it with a literal.