What is the easiest way to handle associative array in c#?

后端 未结 2 1499
星月不相逢
星月不相逢 2021-01-30 10:26

I do not have a lot of experience with C#, yet I am used of working with associative arrays in PHP.

I see that in C# the List class and the Array are available, but I wo

2条回答
  •  臣服心动
    2021-01-30 11:04

    Use the Dictionary class. It should do what you need. Reference is here.

    So you can do something like this:

    IDictionary dict = new Dictionary();
    dict["red"] = 10;
    dict["blue"] = 20;
    

提交回复
热议问题