I don't have any problem when I tried to get the keys, but I was having a problem when I tried to get the value from a Dictionary. The values is a class that contains 2 fields with a constructor with 2 parameters. Here is the code :
    public class SetupWeapon {
        public int poolSize;
        public GameObject prefab;
        public SetupWeapon(int size, GameObject goPrefab) {
            this.poolSize = size;
            this.prefab = goPrefab;
        }
    }
    private SetupWeapon[] _setupWeapon = new SetupWeapon[1];
    private Dictionary<int, SetupWeapon> _weaponData = new Dictionary<int, SetupWeapon>();
    public int[] AttackIDs {
        get {
            var toArray = _weaponData.Select(a => a.Key).ToArray();
            return toArray;
        }
    }
    private int[] PoolSize {
        get {
            var toArray = _weaponData.Select(a => a.Value.poolSize).ToArray();
            return toArray;
        }
    }
    private GameObject[] Prefab {
        get {
            var toArray = _weaponData.Select(a => a.Value.prefab).ToArray();
            return toArray;
        }
    }
    void Start () {
        CollectData(setPhysical); // collecting data
        CollectData(setLeftEye);
        CollectData(setRightEye);
        CollectData(setForehead);
        CollectData(setMouth);
        for (int i = 0; i < AttackIDs.Length; i++){
            Debug.Log(AttackIDs[i]); // works just fine
            Debug.Log(_weaponData[0].poolSize); // works just fine
            Debug.Log(_weaponData[0].prefab.name); // works just fine
            Debug.Log(PoolSize[0]); // NullReferenceException
            Debug.Log(Prefab[0].name); // NullReferenceException
        }
    }
Did I miss something important that cause this error ?
 
     
    