C# phau ntawv txhais lus yog dab tsi?
C# phau ntawv txhais lus yog dab tsi?

Video: C# phau ntawv txhais lus yog dab tsi?

Video: C# phau ntawv txhais lus yog dab tsi?
Video: Npau Suav Pom Mus Kawm Ntawv Txhais Tau Li Cas/ Tus Lej Twg 2024, Kaum ib hlis
Anonim

Hauv C# , Phau ntawv txhais lus yog ib tug generic sau uas feem ntau yog siv los khaws cov key/value khub. Kev ua haujlwm ntawm Phau ntawv txhais lus Nws zoo ib yam li cov uas tsis yog-generic hashtable. Qhov zoo ntawm Phau ntawv txhais lus yog, nws yog hom generic. Phau ntawv txhais lus yog txhais raws li System.

Ib yam li ntawd, tib neeg nug, Dab tsi yog qhov txawv ntawm Hashtable thiab Dictionary hauv C #?

Hashable yog ib qho yooj yim ntaus ntawv (tsis yog-generic), qhov no txhais tau tias nws khaws cov khoom tseem ceeb ntawm cov ntaub ntawv hom. Phau ntawv txhais lus yog ib tug generic collection. Yog li nws tuaj yeem khaws cov khoom tseem ceeb ntawm cov ntaub ntawv tshwj xeeb. Mus saib Hashable los yog Phau ntawv txhais lus hauv C# tshooj lus qhia kom paub ntxiv.

Ib yam li ntawd, KeyValuePair C# yog dab tsi? KeyValuePair hauv C# CsharpProgrammingServer Side Programming. Cov KeyValuePair chav kawm khaws ib khub ntawm qhov tseem ceeb hauv ib daim ntawv teev npe nrog C# . Teeb KeyValuePair thiab ntxiv cov ntsiab lus − var myList = New List< KeyValuePair > (); // ntxiv cov ntsiab lus myList.

Ib yam li ntawd, nws tau nug, yog phau ntawv txhais lus siv hom C#?

Yog tias Hom ntawm tus nqi ntawm cov phau ntawv txhais lus yog tus nqi hom ces tus nqi tiag tiag yuav tau theej. hom siv yog khaws cia li cov ntaub ntawv ib txwm. tus nqi hom tau theej (simplistically byte sawv cev luam yog tsim, txawm li cas los xij tag nrho siv tseem yuav muaj nqis cov ntaub ntawv ), tshwj tsis yog dhau los ua ref rau cov haujlwm.

Qhov twg yog phau ntawv txhais lus sai dua lossis Hashtable?

A Phau ntawv txhais lus ntawm ib hom tshwj xeeb (lwm yam tsis yog Object) muaj kev ua tau zoo dua li a Hashable rau hom nqi vim cov ntsiab lus ntawm Hashable yog hom Object thiab, yog li ntawd, boxing thiab unboxing feem ntau tshwm sim yog khaws cia los yog retrieving ib tug nqi hom.

Pom zoo: