In an attempt to build a Dictionary object that is seeded with all possible system statuses as the keys and 0 for each value, I have the following code that loops through the Enum that contains system status info:
Dictionary<string, int> statusAccumulator = new Dictionary<string, int>();
// initialize statusAccumulator with all possible system statuses
foreach (var status in Enum.GetNames(typeof(SystemTaskRequestStatus)))
{
statusAccumulator[status] = 0;
}
and here is the Enum for system status:
public enum SystemStatus
{
[EnumString("PN")]
Pending,
[EnumString("RT")]
Retry,
[EnumString("IP")]
InProgress,
[EnumString("C")]
Complete,
[EnumString("F")]
Failed,
[EnumString("T")]
Test
}
With this code, the keys in the Dictionary are: Pending, Retry, InProgress, Complete, Failed, Test. However, I want the EnumStrings as the keys - PN, RT, IP, C, F, T. How can the code be modified to achieve this?