二维数组,可以用于 物品ID 和 物品 名称 的预设置。
Dictionary<string, string> testDict = new Dictionary<string, string>() { ["key1"] = "value1", ["key2"] = "value2" };
var testDict = new Dictionary<string, string>() { ["key1"] = "value1", ["key2"] = "value2" };
查找的 变量 必须 唯一
...
using System;
using System.Collections.Generic;
...
var testDict = new Dictionary<string, string>() { ["key1"] = "value1", ["key2"] = "value2" };
...
if (test_array.ContainsKey(1))//通过int变量 来查找 对应 的字符串
{
string value = test_array[1];
//Console.WriteLine(value);
Debug.Log(value);//输出:test1
}//https://www.codegrepper.com/code-examples/csharp/c%23+dictionary+get+value+by+key