উত্তর:
KeyValuePair<TKey,TValue>DictionaryEntryএটি উদার করা হয় কারণ জায়গায় ব্যবহৃত হয় । একটি ব্যবহার করার সুবিধাটি KeyValuePair<TKey,TValue>হ'ল আমরা আমাদের অভিধানে কী আছে সে সম্পর্কে সংকলকটিকে আরও তথ্য দিতে পারি। ক্রিসের উদাহরণকে প্রসারিত করতে (এতে আমাদের <string, int>জোড়া রয়েছে এমন দুটি অভিধান রয়েছে )।
Dictionary<string, int> dict = new Dictionary<string, int>();
foreach (KeyValuePair<string, int> item in dict) {
int i = item.Value;
}
Hashtable hashtable = new Hashtable();
foreach (DictionaryEntry item in hashtable) {
// Cast required because compiler doesn't know it's a <string, int> pair.
int i = (int) item.Value;
}
কীভ্যালিউপায়ার <টি, টি> অভিধান <টি, টি> এর মাধ্যমে পুনরাবৃত্তি করার জন্য। এটি কাজগুলি করার নেট নেট 2 (এবং এরপরে)।
হ্যাশ টেবিলগুলির মাধ্যমে পুনরাবৃত্তি করার জন্য অভিধানইন্ট্রি। এটি কাজগুলি করার নেট। 1 উপায়।
এখানে একটি উদাহরণ:
Dictionary<string, int> MyDictionary = new Dictionary<string, int>();
foreach (KeyValuePair<string, int> item in MyDictionary)
{
// ...
}
Hashtable MyHashtable = new Hashtable();
foreach (DictionaryEntry item in MyHashtable)
{
// ...
}