有关集合的问题
using System;using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
namespace 上寨微博
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Hashtable table = new Hashtable();
private void textBox1_TextChanged(object sender, EventArgs e)
{
table.Clear();//这里不懂?
//1.检查个数
string str = textBox1.Text.Trim();
int num = str.Length;
int numTotal = 140;
int dif = numTotal - num;
//2.统计个数
for (int i = 0; i < str.Length; i++)
{
//看看这个字符串在集合中是否存在,如果存在个数加一
//不存在,将其加进去,将个数初始化为1
string current = str[i].ToString();
if (table.ContainsKey(current))
{
//存在
int numTemp = Convert.ToInt32(table[current]);
table[current] = numTemp + 1;
}
else
{
//不存在
table.Add(current, 1);
}
}
//3.显示统计结果与总数
StringBuilder sb = new StringBuilder();
foreach (DictionaryEntry item in table)
{
sb.AppendFormat("汉字{0},出现{1}\r\n",item.Key,item.Value);
}
label1.Text = sb.ToString();
//4.考虑按钮是否可用
label2.Text = dif.ToString();
if (dif<0)
{
button1.Enabled = false;
}
else
{
button1.Enabled = true;
}
}
}
}
请问这里table.Clear()是什么意思