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