2
我想通过使用字符串以将其复制到新字典中来查找字典 - 看起来应该很简单,但我不确定语法。使用字符串查找C#字典
基本上它只是:
// the object's myName corresponds to an existing dictionary
string stringdic = myName;
// here's where I try to create a new dictionary containing the values of the existing dictionary
Dictionary<string, int> mySkills = new Dictionary<string, int>(myName);
这里的目标就是要与给定的字符串作为其“名”,并从名字知道哪个出了一套词典它应该使用创建一个对象 - - 例如,如果myName = Bob,我想在此脚本中访问字典Bob。
因此,引用预先存在的字典以获取其键/值的其他方式也可以工作。速度不是一个大问题,但我想保持代码简单。谢谢!
谢谢,这对我正在做的事很完美。 – 2013-04-30 01:47:32