Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. HashTable Problem

HashTable Problem

Scheduled Pinned Locked Moved C#
helpcsharpvisual-studioquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    ytubis
    wrote on last edited by
    #1

    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 :)

    C 1 Reply Last reply
    0
    • Y ytubis

      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 :)

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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 )

      Y 1 Reply Last reply
      0
      • C Christian Graus

        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 )

        Y Offline
        Y Offline
        ytubis
        wrote on last edited by
        #3

        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]); }

        C 1 Reply Last reply
        0
        • Y ytubis

          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]); }

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          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 )

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups