第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

Hashtable和Dictionary<T,K>的內(nèi)部排序

Hashtable和Dictionary<T,K>的內(nèi)部排序

蕪湖不蕪 2018-12-07 00:45:00
Hashtable和Dictionary<T,K>的內(nèi)部排序算法不一樣,請(qǐng)看代碼         Dictionary<string,string> ht=new Dictionary<string, string>();        ht.Add("http://www.sina.com.cn","");        ht.Add("http://www.bjut.edu.cn","");        ht.Add("http://lib.bjut.edu.cn", "");        ht.Add("http://news.bjut.edu.cn", "");        ht.Add("http://sse.bjut.edu.cn", "");        ht.Add("http://lexus.cnblogs.com", "");        ht.Add("http://www.sina.com.cn/sport", "");        ht.Add("http://www.sina.com.cn/ent", "");        foreach(var kvp in ht)            Console.WriteLine(kvp.Key);        Console.WriteLine("============================================");        Hashtable ht2=new Hashtable();        ht2.Add("http://www.sina.com.cn", "");        ht2.Add("http://www.bjut.edu.cn", "");        ht2.Add("http://lib.bjut.edu.cn", "");        ht2.Add("http://news.bjut.edu.cn", "");        ht2.Add("http://sse.bjut.edu.cn", "");        ht2.Add("http://lexus.cnblogs.com", "");        ht2.Add("http://www.sina.com.cn/sport", "");        ht2.Add("http://www.sina.com.cn/ent", "");        foreach(DictionaryEntry i in ht2)            Console.WriteLine(i.Key); 兩組實(shí)現(xiàn)的代碼一樣,但是輸出的排序結(jié)果不一樣,這是為什么,我覺得Hashtable的排序應(yīng)該是比較正常的,大家覺得呢?
查看完整描述

3 回答

?
慕運(yùn)維8079593

TA貢獻(xiàn)1876條經(jīng)驗(yàn) 獲得超5個(gè)贊

Dictionary默認(rèn)沒有排序的意思是它將按你Add的順序來(lái)存放,本身不會(huì)做排序操作 Hashtable的排序是根據(jù)Key的HashCode來(lái)進(jìn)行的,HashCode來(lái)自于Key的GetHashCode方法,一般值類型都直接使用系統(tǒng)已經(jīng)實(shí)現(xiàn)的GetHashCode方法,但引用類型多數(shù)情況下建議重寫GetHashCode()
查看完整回答
反對(duì) 回復(fù) 2019-01-21
?
繁星淼淼

TA貢獻(xiàn)1775條經(jīng)驗(yàn) 獲得超11個(gè)贊

兩者都相當(dāng)于無(wú)序集合,順序是無(wú)所謂的.
查看完整回答
反對(duì) 回復(fù) 2019-01-21
  • 3 回答
  • 0 關(guān)注
  • 531 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)