我有數據庫篩選之前現在哪些數據結構更好?
ItemName Price
針對項目名稱我曾在哈希表的價格。我的一些代碼是這樣的
Hashtable pricesTilesBox = new Hashtable();
string itemNameData=myReader["ItemName"].ToString().Trim();
int price=Convert.ToInt32(myReader["Price"]);
pricesTilesBox.Add(itemNameData,price);
foreach (string key in pricesTilesBox.Keys)
{
Console.WriteLine(key + '=' + pricesTilesBox[key]);
}
但現在我已經改變數據庫表
ItemName PriceLight PriceDark
所以其數據結構,現在可以使用我可以得到PriceLight PriceDark
對itemName
。因爲有兩個現在的價格。哈希表可以用在這種情況下嗎?
這個線程可以幫助http://stackoverflow.com/questions/166089/what-is-c-sharp-analog-of-c-stdpair使兩個_Price_值中的一對,並添加對到Hashtable –