net中移动Hashtable中的数据

net中移动Hashtable中的数据

本文介绍了如何在c#.net中移动Hashtable中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





如何在哈希表中逐个查看数据。例如,当我单击下一步按钮,然后逐个显示数据。

Hi,

how to view the data one by one in hashtable. for example when i click the "Next" button then show data one by one.

推荐答案

Hashtable ht = new Hashtable();
ht.Add("0", "One");
ht.Add("1", "Two");
ht.Add("2", "Three");
ht.Add("3", "Four");
  int i=1;
private void button1_Click(object sender, RoutedEventArgs e)
        {
        string in="\""+i+"\"";
        txtObjects.Text =i.tostring();
          txtValues.Text = ht[in] ;
          i = (ht.Count % i) + 1;
        }


Quote:





通常Hashtable用于以Key和Value对的格式存储数据。

假设我们要将数据添加到Hashtable中。





Hashtable ht = new Hashtable();

ht.Add(1,One );

ht.Add(2,Two);

ht.Add(3,Three);

ht.Add(4,Four);



Hashtable中的元素可以使用DictionaryEntry类访问,例如

foreach(DictionaryEntry de in ht)

{

txtObjects.Text = txtObjects.Text +,+ de.Key.ToString();

txtValues.Text = txtValues.Text +,+ de.Value.ToString();

}





其中txtObjects和txtValues是.aspx页面中控件的ID

Hi,

Generally Hashtable is used to store data in the format of Key and Value pairs.
Assume that we are going to add data to Hashtable like this.


Hashtable ht = new Hashtable();
ht.Add("1", "One");
ht.Add("2", "Two");
ht.Add("3", "Three");
ht.Add("4", "Four");

The elements in the Hashtable can be accessed using DictionaryEntry class like
foreach (DictionaryEntry de in ht)
{
txtObjects.Text = txtObjects.Text + "," + de.Key.ToString();
txtValues.Text = txtValues.Text + "," + de.Value.ToString();
}


where txtObjects and txtValues are the ID of the control in .aspx page




这篇关于如何在c#.net中移动Hashtable中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 11:09