Results 1 to 12 of 12

Thread: How retrieve data from hash table output

Hybrid View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    241

    Thumbs up How read a hash table object

    Hi friends,

    I am in problem. I am using Asp.Net 2.0 application.I got an output in hash table like

    System.Collections.Hashtable
    Key: ashok.org
    Value:
    System.Collections.Hashtable
    Key: status
    Value:
    available
    Key: classkey
    Value:
    domorg

    The above hash table output i got it. I want to read this hash table object and i need to get the Key and value both.

    I can create hash table object and using IDictionary i can get these Key and Value. But first time i can get Key and write it. Here my Value is in object type and inside I have Key and Value. How can i read the object?? and get the Key and Value inside of Value. Please give me suggestion. Hope yours reply.
    Failing to plan is Planning to fail

  2. #2
    Fanatic Member karthikeyan's Avatar
    Join Date
    Oct 2005
    Location
    inside .net
    Posts
    919

    Re: How read a hash table object

    hi, Try the follwoing code. this code shows the key and values also.
    Code:
    Hashtable exampleTable = new Hashtable();
                exampleTable.Add("txt", "notepad.exe");
                exampleTable.Add("bmp", "paint.exe");
                exampleTable.Add("dib", "paint.exe");
                exampleTable.Add("rtf", "wordpad.exe");
                foreach (string key in exampleTable.Keys)
                {
                    Response.Write(exampleTable[key].ToString(),key);
                }
    Good luck.
    Loving dotnet

  3. #3
    New Member
    Join Date
    Jul 2012
    Posts
    1

    Re: How read a hash table object

    IDictionaryEnumerator s = hashtable.GetEnumerator();
    while (s.MoveNext())
    {
    MessageBox.Show(s.Key + s.Value.ToString());
    }

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: How read a hash table object

    Quote Originally Posted by prasad.k539 View Post
    IDictionaryEnumerator s = hashtable.GetEnumerator();
    while (s.MoveNext())
    {
    MessageBox.Show(s.Key + s.Value.ToString());
    }
    Hello,

    Welcome to the forums! Thanks for taking the time to post in this thread!

    One thing I would say though, using MessageBox.Show within an ASP.NET application is not really a recommended best practice. Although it will "work" when you are debugging out of Visual Studio, when you deploy the application onto a server, you will never see the MessageBox appear on the client.

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width