如何为类实例提供现有变量的名称.我这样想string hex = "BF43F"; Zeugh hex = new Zeugh();但是错了.我想创建一个具有Zeugh类属性的对象BF43F.
听起来像你想要的Dictionary<string, Zeugh>.例如:
var d = new Dictionary<string, Zeugh>();
string hex = "BF43F";
d.Add(hex, new Zeugh());
Run Code Online (Sandbox Code Playgroud)
(后来)
Zeugh it = d["BF43F"];
Run Code Online (Sandbox Code Playgroud)