C#中Dictionary字典取值


// Create a new dictionary of strings, with string keys.
//
Dictionary<stringstringopenWith =
new Dictionary<stringstring>();
 
// When you use foreach to enumerate dictionary elements,
// the elements are retrieved as KeyValuePair objects.
Console.WriteLine();
foreachKeyValuePair<stringstringkvp in openWith )
{
Console.WriteLine("Key = {0}, Value = {1}",
kvp.Keykvp.Value);
}
// To get the values alone, use the Values property.
Dictionary<stringstring>.ValueCollection valueColl =
openWith.Values;
 
// The elements of the ValueCollection are strongly typed
// with the type that was specified for dictionary values.
Console.WriteLine();
foreachstring in valueColl )
{
Console.WriteLine("Value = {0}"s);
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM