Creating a constant Dictionary in C#

前端 未结 10 2078
独厮守ぢ
独厮守ぢ 2020-12-04 08:21

What is the most efficient way to create a constant (never changes at runtime) mapping of strings to ints?

I\'ve tried us

10条回答
  •  独厮守ぢ
    2020-12-04 09:02

    enum Constants
    {
        Abc = 1,
        Def = 2,
        Ghi = 3
    }
    
    ...
    
    int i = (int)Enum.Parse(typeof(Constants), "Def");
    

提交回复
热议问题