How can i give a class instance the name of an existing variable. I am trying like this string hex = "BF43F"; Zeugh hex = new Zeugh();
but its wrong. I want to create an object BF43F with the properties of Zeugh class.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
Sounds like you want a
Dictionary<string, Zeugh>
. For example:(later)
You can't declare two variables with the same name in the same scope.
If you later access the variable
hex
, how should the compiler know if you mean the "BF43F" string or theZeugh
object?Or do you want an object with the same properties as a
Zeugh
object, but with one additional string property to save your string "BF43F" in?You could create another class which inherits from
Zeugh
and has an additional string property:Then, you can store your string "BF43F" in this property: