I'm trying to convert an Enumeration to a Dictionary using LINQ
Here is what I have so far:
// returns a dictionary populated with the relevant keys
public Dictionary<string, string> StartNewEntry()
{
return Enum.GetNames(typeof(TableDictionary)).ToDictionary(Key =>
(string)Enum.Parse(typeof(TableDictionary), Key), value => "");
}
Its giving me issues when trying to cast the key.
Unable to cast object of type 'InventoryImportExportLibrary.TableDictionary' to type 'System.String'.
I'm looking for this:
public enum TableDictionary
{
Barcode = 0,
FullName = 1,
Location = 2,
Notes = 3,
Category = 4,
Timestamp = 5,
Description = 6
}
With a dictionary thats
["Barcode", ""]
I'm not sure what suits does here. I do want the string because I need to use it later in my program for comparisons.