本文介绍了如何在TEXTBOX或Gridview中显示HashTable?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好!!希望每一个人都很好!!!!!
我是c#编程的新手,我正在制作一个程序,我必须在其中显示HASHTABLE键和值对TEXTBOX或GRIDVIEW ....
换句话说我想在我的表单应用程序中显示hashTable ....
那怎么能这样做我搜索了很多但找不到...
亲切的帮助我用代码示例..
Hello!! Hope every One is fine !!!!!
I am new to c# programming and i am making a program in which i have to display HASHTABLE key and value pair in the TEXTBOX or in GRIDVIEW....
In other words i want to display hashTable in my form application....
So how could do this i have searched a lot but could not find...
Kindly assist me with code example..
推荐答案
Hashtable ht = new Hashtable();
ht.Add("Hello", "there");
ht.Add(1, "Banana");
StringBuilder sb = new StringBuilder();
foreach (object key in ht.Keys)
{
sb.AppendFormat("{0} = {1}\n", key, ht[key]);
}
string lines = sb.ToString();
然后你可以用字符串做任何你喜欢的事情,或使用GridView而不是StringBuilder。
You can then do whatever you like with the string, or use a GridView instead of the StringBuilder.
这篇关于如何在TEXTBOX或Gridview中显示HashTable?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!