相关疑难解决方法(0)

枚举到字典c#

我在网上搜索但无法找到我要找的答案.基本上我有以下枚举:

public enum typFoo : int
{
   itemA : 1,
   itemB : 2
   itemC : 3
}
Run Code Online (Sandbox Code Playgroud)

如何将此枚举转换为Dictionary,以便它存储在以下字典中

Dictionary<int,string> mydic = new Dictionary<int,string>();
Run Code Online (Sandbox Code Playgroud)

和mydic看起来像这样:

1, itemA
2, itemB
3, itemC
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

c# collections enums dictionary

56
推荐指数
5
解决办法
6万
查看次数

标签 统计

c# ×1

collections ×1

dictionary ×1

enums ×1