主题:Hashtable 集合问题
我定义了一个方法 这个方法中有一个集合
我创建了对象去调这个方法
可是出了异常
Hashtable hashatble =new Hashtable();
public void kk(){
string aa=(string )this.hasahtable[键值];
}
************** 异常文本 **************
System.NullReferenceException: 未将对象引用设置到对象的实例。
at 第九阶段第三部分.Form1.kk() in f:\。net\。net\第九阶段第三部分\form1.cs:line 264
at 第九阶段第三部分.Form2.sou2_Click(Object sender, EventArgs e) in f:\。net\。net\第九阶段第三部分\form2.cs:line 114
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
我创建了对象去调这个方法
可是出了异常
Hashtable hashatble =new Hashtable();
public void kk(){
string aa=(string )this.hasahtable[键值];
}
************** 异常文本 **************
System.NullReferenceException: 未将对象引用设置到对象的实例。
at 第九阶段第三部分.Form1.kk() in f:\。net\。net\第九阶段第三部分\form1.cs:line 264
at 第九阶段第三部分.Form2.sou2_Click(Object sender, EventArgs e) in f:\。net\。net\第九阶段第三部分\form2.cs:line 114
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)