如何为String.String分配字符串 [英] How Do I Assign String To Label.String
本文介绍了如何为String.String分配字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要兑换这个
Hashtable [labelA1] = labelA1。文本;
到下面
字符串k;
k =labelA1;
Hashtable [labelA101] =字符串到标签(k);
解决方案
你将如何做到这将取决于运行代码的环境:第一点很简单:
string k = labelA1;
Hashtable [k] = ...
这是第二位发生变化。
对于基于网络的,那么这可能会它:
string = < span class =code-string> labelA1;
控制c = FindControl(k);
标签l = c as 标签;
if (l!= null )
{
Hashtable [ K] = l.Text;
}如果不是,那么我们需要知道你在运行什么......
HI
I want to convert this
Hashtable["labelA1"]=labelA1.Text;
to Below
string k;
k="labelA1";
Hashtable["labelA101"]=string to label("k");
解决方案
How exactly you would do that would depend on the environment your code is running in: The first bit is easy:
string k = "labelA1"; Hashtable[k] = ...
It's the second bit that changes.
For web based, then this might do it:
string = "labelA1"; Control c = FindControl(k); Label l = c as Label; if (l != null) { Hashtable[k]=l.Text; }If it isn't, then we need to know what you are running in...
这篇关于如何为String.String分配字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文