kingBook

导航

Unity3d中Dictionary和KeyValuePair的使用

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class test : MonoBehaviour { void Start () { Dictionary<int,object> dict = new Dictionary<int,object> (); dict.Add (0,new Vector2(0,0)); dict.Add (1,new Vector2(1,1)); dict.Add (2,new Vector3(2,2)); dict.Add (3,"abcd"); foreach (KeyValuePair<int,object> pair in dict) { Debug.Log (pair.Key+", "+pair.Value); } //0, (0.0, 0.0) //1, (1.0, 1.0) //2, (2.0, 2.0, 0.0) //3, abcd } }

 

posted on 2016-10-28 16:12  kingBook  阅读(1449)  评论(0编辑  收藏  举报