通过变量名引用值 [英] Referencing value by variable name
本文介绍了通过变量名引用值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以通过引用变量名来获取变量的内容.我有一堆变量,比如
Is it possible to obtain the content of a variable by referencing to its name. I have a bunch of variables like
Dim _tipoEntero As String = "^[0-9].$"
Dim _tipoTelefono As String = "^[0-9]{6}$"
我试图引用像
myValue = GetVariableValue("_tipo" + validationString)
推荐答案
您可以使用 字典.
Dim tipos As New Dictionary(Of String, String)
tipos.Add("Entero", "^[0-9].$")
tipos.Add("Telefono", "^[0-9]{6}$")
myValue = tipo(validationString)
这篇关于通过变量名引用值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文