赋予一个类的实例的变量的名称 [英] giving a class instance the name of a variable

查看:113
本文介绍了赋予一个类的实例的变量的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么可以给一个类实例的现有变量的名称。我想这样的字符串十六进制=BF43F; Zeugh十六进制=新Zeugh(); 但它是错误的。我想创建Zeugh类的属性的对象BF43F。

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.

推荐答案

听起来像是你想有一个字典<字符串,Zeugh> 。例如:

Sounds like you want a Dictionary<string, Zeugh>. For example:

var d = new Dictionary<string, Zeugh>();
string hex = "BF43F"; 
d.Add(hex, new Zeugh());



(后下)

(later)

Zeugh it = d["BF43F"];

这篇关于赋予一个类的实例的变量的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆