//我以為這裡可以和c++中的map一樣,可以直接賦值,但是會報錯
//這裡不能這樣直接賦值
//然後我是用方法1中那種方式處理的,但我感覺這麼處理很麻煩
//然後我在csdn論壇上問了下,然後我換成方法2,這種方法可以直接賦值,不再那麼繁瑣
//可以說是各有各的好處吧

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DictionaryDemoQ
{
    class Program
    {
        public struct Data
        {
            public int a;
            public int b;
        }

        static void Main(string[] args)
        {
            //方法1
            Dictionary<int, Data> data = new Dictionary<int, Data>();
            Data d = new Data();
            for (int i = 0; i < 3; i++ )
            {
                d.a = i + 1;
                d.b = i + 2;
                data.Add(i, d);
            }

            for (int i = 0; i < 3; i++ )
            {
                Data da = data[i];
                da.a = 10;
                da.b = 20;
                data[i] = da;
            }


            //方法2
            Dictionary<int, TempD> temp_d = new Dictionary<int, TempD>();
            TempD t_d = new TempD();
            for (int i = 0; i < 3; i++)
            {
                t_d.temp1 = i + 1;
                t_d.temp1 = i + 2;
                temp_d.Add(i, t_d);
            }

            for (int i = 0; i < 3; i++ )
            {
                temp_d[i].temp1 = 20;
            }
        }
    }

    public class TempD
    {
        public int temp1;
        public int temp2;
    }
}