Proper way to initialize a C# dictionary with values

Note that C# 9 allows Target-typed new expressions so if your variable or a class member is not abstract class or interface type duplication can be avoided: private readonly Dictionary FILE_TYPE_DICT = new () { { “csv”, XlFileFormat.xlCSV }, { “html”, XlFileFormat.xlHtml } };

Read More