Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi,

I've encountered a really strange thing.

I have this code:

m_sFilename = Dict.ChildKeys["Filename"].ToString();

 

which basicaly places the value of the string object stored in the Dict.ChildKeys hashtable into the string variable m_sFilename.

 

The problem is, the expression Dict.ChildKeys["Filename"] returns null, and so m_sFilename now contains an empty string.

 

The thing is, that I then tried explicitly telling the interpreter that the "ChildKeys" property returns a hashtable (see code below) and now it returns the correct value of the object stored in the hashtable.

m_sFilename = ((System.Collections.Hashtable)(Dict.ChildKeys))["Filename"].ToString();

 

Any ideas why this would happen? I can leave my Sourcecode like in the lower code example, but that isn't as readable and is ugly.

 

Any ideas?

Latly it would seem as though I'm don't abnegate from anything... except women. :( :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...