如何遍历C# 中 Dictionary。

    关键利用KeyValuePair。

    定义一个Dictionary:

    Dictionary<int,Point> aggUpGroupPointDic = new Dictionary<int, Point>();

   遍历它:

   foreach (KeyValuePair<int,Point>keyValuePair  inaggDownGroupPointDic)

  {

     Console.WriteLine(“Point{0}’s position is ({1},{2})”,keyValuePair.Key,keyValuePair.Value.X,keyValuePair.Value.Y);

  }

你可能感兴趣的:(如何遍历C# 中 Dictionary。)