日期:2014-05-20  浏览次数:20799 次

HashTable问题,产生异常是什么原因呢?
using   System;
using   System.Drawing;
using   System.Collections;
using   System.ComponentModel;
using   System.Windows.Forms;
using   System.Data;

namespace   HashTable
{
///   <summary>
///   Form1   的摘要说明。
///   </summary>
public   class   Form1   :   System.Windows.Forms.Form
{
private   Hashtable   _hashtable=new   Hashtable();
private   System.Windows.Forms.GroupBox   groupBox1;
private   System.Windows.Forms.Label   label1;
private   System.Windows.Forms.Label   label2;
private   System.Windows.Forms.Label   label3;
private   System.Windows.Forms.Label   label4;
private   System.Windows.Forms.TextBox   txtKey;
private   System.Windows.Forms.TextBox   txtValue;
private   System.Windows.Forms.Button   btnAdd;
private   System.Windows.Forms.ListBox   lstAddedKey;
private   System.Windows.Forms.TextBox   txtSelectedValue;
///   <summary>
///   必需的设计器变量。
///   </summary>
private   System.ComponentModel.Container   components   =   null;

public   Form1()
{
//
//   Windows   窗体设计器支持所必需的
//
InitializeComponent();

//
//   TODO:   在   InitializeComponent   调用后添加任何构造函数代码
//
}

///   <summary>
///   清理所有正在使用的资源。
///   </summary>
protected   override   void   Dispose(   bool   disposing   )
{
if(   disposing   )
{
if   (components   !=   null)  
{
components.Dispose();
}
}
base.Dispose(   disposing   );
}

#region   Windows   窗体设计器生成的代码
///   <summary>
///   设计器支持所需的方法   -   不要使用代码编辑器修改
///   此方法的内容。
///   </summary>
private   void   InitializeComponent()
{
this.groupBox1   =   new   System.Windows.Forms.GroupBox();
this.btnAdd   =   new   System.Windows.Forms.Button();
this.txtValue   =   new   System.Windows.Forms.TextBox();
this.txtKey   =   new   System.Windows.Forms.TextBox();
this.label2   =   new   System.Windows.Forms.Label();
this.label1   =   new   System.Windows.Forms.Label();
this.label3   =   new   System.Windows.Forms.Label();
this.lstAddedKey   =   new   System.Windows.Forms.ListBox();
this.label4   =   new   System.Windows.Forms.Label();
this.txtSelectedValue   =   new   System.Windows.Forms.TextBox();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//  
//   groupBox1
//  
this.groupBox1.Controls.Add(this.btnAdd);
this.groupBox1.Controls.Add(this.txtValue);
this.groupBox1.Controls.Add(this.txtKey);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Location   =   new   System.Drawing.Point(8,   8);
this.groupBox1.Name   =   "groupBox1 ";
this.groupBox1.Size   =   new   System.Drawing.Size(280,   120);
this.groupBox1.TabIndex   =   0;
this.groupBox1.TabStop   =   false;