how to get value from hash table
-
hi friend i have hash table where we store key and value. on value place i stored one more hash table so how i get that value which is store in value hash table help me
Piyush Vardhan Singh Programmer TAS NewDelhi India 9313077379
-
hi friend i have hash table where we store key and value. on value place i stored one more hash table so how i get that value which is store in value hash table help me
Piyush Vardhan Singh Programmer TAS NewDelhi India 9313077379
Hi Friend: Here is code for getting child hashtable value. //Make main Hash table Hashtable mainHashTable = new Hashtable(); //Make child Hash Table Hashtable childHashTable = new Hashtable(); //Add child hash table value childHashTable.Add("ChildValue", "Mubashir"); //Add child hash table to main hash table mainHashTable.Add("HashTable", childHashTable); //Get Child Hash table value ((Hashtable)mainHashTable["HashTable"])["ChildValue"].ToString()
-
Hi Friend: Here is code for getting child hashtable value. //Make main Hash table Hashtable mainHashTable = new Hashtable(); //Make child Hash Table Hashtable childHashTable = new Hashtable(); //Add child hash table value childHashTable.Add("ChildValue", "Mubashir"); //Add child hash table to main hash table mainHashTable.Add("HashTable", childHashTable); //Get Child Hash table value ((Hashtable)mainHashTable["HashTable"])["ChildValue"].ToString()
but i have many walu in child hash table like this:- Dim ConfId As String Dim meesage As String Dim SinglNode As System.Xml.XmlNode = xRequests.SelectSingleNode("/cwaEvents/conference") ConfId = SinglNode.Attributes("confId").InnerText Dim SinglNode1 As System.Xml.XmlNode = xRequests.SelectSingleNode("/cwaEvents/conference/messageReceived/message/content") If SinglNode1.InnerText <> "" Then meesage = SinglNode1.InnerText 'M_MessageTextHTAble = M_MessageHTAble.Item(ConfId) M_Messagecounter = M_Messagecounter + 1 M_MessageTextHTAble.Add(M_Messagecounter, meesage) M_MessageHTAble.Remove(ConfId) M_MessageHTAble.Add(ConfId, M_MessageTextHTAble) End If Return M_MessageHTAble
Piyush Vardhan Singh Programmer TAS NewDelhi India 9313077379
-
but i have many walu in child hash table like this:- Dim ConfId As String Dim meesage As String Dim SinglNode As System.Xml.XmlNode = xRequests.SelectSingleNode("/cwaEvents/conference") ConfId = SinglNode.Attributes("confId").InnerText Dim SinglNode1 As System.Xml.XmlNode = xRequests.SelectSingleNode("/cwaEvents/conference/messageReceived/message/content") If SinglNode1.InnerText <> "" Then meesage = SinglNode1.InnerText 'M_MessageTextHTAble = M_MessageHTAble.Item(ConfId) M_Messagecounter = M_Messagecounter + 1 M_MessageTextHTAble.Add(M_Messagecounter, meesage) M_MessageHTAble.Remove(ConfId) M_MessageHTAble.Add(ConfId, M_MessageTextHTAble) End If Return M_MessageHTAble
Piyush Vardhan Singh Programmer TAS NewDelhi India 9313077379
Step 1 : Get the Fist M_MessageTextHTAble from the M_MessageHTAble by ConfId Step 2 : Get the all item from M_MessageTextHTAble by For each statement
Parwej Ahamad g.parwez@gmail.com
-
but i have many walu in child hash table like this:- Dim ConfId As String Dim meesage As String Dim SinglNode As System.Xml.XmlNode = xRequests.SelectSingleNode("/cwaEvents/conference") ConfId = SinglNode.Attributes("confId").InnerText Dim SinglNode1 As System.Xml.XmlNode = xRequests.SelectSingleNode("/cwaEvents/conference/messageReceived/message/content") If SinglNode1.InnerText <> "" Then meesage = SinglNode1.InnerText 'M_MessageTextHTAble = M_MessageHTAble.Item(ConfId) M_Messagecounter = M_Messagecounter + 1 M_MessageTextHTAble.Add(M_Messagecounter, meesage) M_MessageHTAble.Remove(ConfId) M_MessageHTAble.Add(ConfId, M_MessageTextHTAble) End If Return M_MessageHTAble
Piyush Vardhan Singh Programmer TAS NewDelhi India 9313077379
This code works for you. You can add different items in child node. These item can be of any type. All you need is type casting. Lets suppose you added SinglNode of XMLNode type in child hash table. You shall use this line for getting that object ((XMLNode)((Hashtable)mainHashTable["HashTable"])["ChildValue"])) This line first get the value of child table then convert it to XMLNode. You can add multiple different objects in hash table. //Make main Hash table Hashtable mainHashTable = new Hashtable(); //Make child Hash Table Hashtable childHashTable = new Hashtable(); //Add child hash table value childHashTable.Add("ChildValue", "Mubashir"); //Add child hash table to main hash table mainHashTable.Add("HashTable", childHashTable); //Get Child Hash table value ((Hashtable)mainHashTable["HashTable"])["ChildValue"].ToString()
-
hi friend i have hash table where we store key and value. on value place i stored one more hash table so how i get that value which is store in value hash table help me
Piyush Vardhan Singh Programmer TAS NewDelhi India 9313077379
This helpful to extract the whole list of key & values when debugging:
Public Shadows Function ToString(ByVal hashTable As Hashtable) As String Dim s As String = String.Empty Dim enumerator As IDictionaryEnumerator = hashTable.GetEnumerator() While (enumerator.MoveNext()) s += enumerator.Key & ": " & enumerator.Value & ControlChars.NewLine End While Return s End Function
Michael
I firmly believe that any man's finest hour, the greatest fulfillment of all that he holds dear, is that moment when he has worked his heart out in a good cause and lies exhausted on the field of battle - victorious. Vince Lombardi (1913-1970)