2013-06-19 30 views
0

[我環顧四周,並沒有找到我正在尋找的直接答案....猜猜它應該是非常簡單的。]在vb.net中序列化散列表?

什麼是一個簡單的方法來將hashTable轉換爲XML並返回在VB.NET中? (我正在使用XML格式將其存儲到數據庫中)

謝謝。


編輯:對於什麼是哈希表的細節 -

給予的具體細節將意味着進入了整個項目的細節。所以,爲了簡便起見考慮下面的例子

dim ht as hashtable 
ht.Add(attribute1,Value1) 
ht.Add(attribute2,Value2) 
ht.Add(attribute3,Value3) 

我想將它轉換成XML,像

<attribute1> 
    <Value1> 
<\attribute1> 
<attribute2> 
    <Value2> 
<\attribute2> 
<attribute3> 
    <Value3> 
<\attribute3> 

我將使用這個XML字符串,將其存儲到數據庫中,表,並在以後使用

+0

是什麼在你的哈希表?你的代碼是什麼? – OneFineDay

+0

@donA請檢查上面的編輯 – Ankitha

+0

序列化一個類對象或'List(Of thatClassObject)'將更適合。 – OneFineDay

回答

0

你不能序列化實現Idictionary接口的任何對象。

<Serializable()> 
Public Class MyFakeHashtable 
    'properties for your key and value 
End Class 

Serialization - MSDN