Dictionary 与 KeyValue 的用法

来源:互联网 发布:阿里云 弹性ip bgp带宽 编辑:程序博客网 时间:2024/05/21 04:20

    using System;  

    using System.Collections.Generic;  

    class Program  

    {  

        static void Main(string[] args)  

        {  

            Dictionary<int, string[]> ff = new Dictionary<int, string[]>();  

            ff.Add(1, new string[2] { "1", "2" });  

            ff.Add(2, new string[2] { "3", "4" });  

            int find = 2;  

            foreach (KeyValuePair<int, string[]> f in ff)  

            {  

                if (f.Key == find)  

                {  

                    foreach (string str in f.Value)  

                    {  

                        Console.WriteLine(str);  

                    }  

                }  

            }  

        }  

    }