HashTable Problem
-
Hi! I have and HashTable object in my class, i initialize it with new as the class creates. I am trying to use the ContainsKey in a function and i get this error: Object reference not set to an instance of an object. at VAControls.clsScheduler.TaskHandle(SchedulerTask[]& taskarray, Int32& counter) in C:\Documents and Settings\Yossi_Tubis\My Documents\Visual Studio 2005\Projects\VASchedular\VASchedular\clsScheduler.cs:line 350 at VAControls.clsScheduler.main_scheduler() in C:\Documents and Settings\Yossi_Tubis\My Documents\Visual Studio 2005\Projects\VASchedular\VASchedular\clsScheduler.cs:line 312 I initialize it, so i do not understand why i get this message. Do you know?? :) Thanks :)
-
Hi! I have and HashTable object in my class, i initialize it with new as the class creates. I am trying to use the ContainsKey in a function and i get this error: Object reference not set to an instance of an object. at VAControls.clsScheduler.TaskHandle(SchedulerTask[]& taskarray, Int32& counter) in C:\Documents and Settings\Yossi_Tubis\My Documents\Visual Studio 2005\Projects\VASchedular\VASchedular\clsScheduler.cs:line 350 at VAControls.clsScheduler.main_scheduler() in C:\Documents and Settings\Yossi_Tubis\My Documents\Visual Studio 2005\Projects\VASchedular\VASchedular\clsScheduler.cs:line 312 I initialize it, so i do not understand why i get this message. Do you know?? :) Thanks :)
Hard to say without seeing the code. Have you used a debugger to see if the hashtable is what's null ?
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
Hard to say without seeing the code. Have you used a debugger to see if the hashtable is what's null ?
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
Yes I did! it show that it is not null and that the count is 0; This is the code: if (m_eventhashtable.ContainsKey(taskarray[counter].SchedularAction)) { if (CheckIfTaskMultiTime(taskarray[counter].SchedularAction)) { //If i contain this Task but it is multiple, then add it to the list of event with number to process. m_eventhashtable.Add(taskarray[counter].SchedularAction + duptaskcounter.ToString(), taskarray[counter]); } else { //if i contain this Task but it is not multiple, then change replace this one for the old one. m_eventhashtable.Remove(taskarray[counter].SchedularAction); m_eventhashtable.Add(taskarray[counter].SchedularAction, taskarray[counter]); } } else { //If i do not contain this Task yet add it to the list of event to process. m_eventhashtable.Add(taskarray[counter].SchedularAction , taskarray[counter]); }
-
Yes I did! it show that it is not null and that the count is 0; This is the code: if (m_eventhashtable.ContainsKey(taskarray[counter].SchedularAction)) { if (CheckIfTaskMultiTime(taskarray[counter].SchedularAction)) { //If i contain this Task but it is multiple, then add it to the list of event with number to process. m_eventhashtable.Add(taskarray[counter].SchedularAction + duptaskcounter.ToString(), taskarray[counter]); } else { //if i contain this Task but it is not multiple, then change replace this one for the old one. m_eventhashtable.Remove(taskarray[counter].SchedularAction); m_eventhashtable.Add(taskarray[counter].SchedularAction, taskarray[counter]); } } else { //If i do not contain this Task yet add it to the list of event to process. m_eventhashtable.Add(taskarray[counter].SchedularAction , taskarray[counter]); }
ytubis wrote:
if (m_eventhashtable.ContainsKey(taskarray[counter].SchedularAction))
is taskarray[counter] null ?
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )