Declare and instantiate a Dictionary in one line

Hi

Building a Windows desktop application and getting a strange Nulll reference error on my dictionary.

I am declaring my dictionary as follows at the top of my Class

     Dictionary<int, GameObject> myDictionary = new Dictionary<int, GameObject>();

Should I instead declare it and then instantiate it separately wihtin my Start method?

ie

        Dictionary<int, GameObject> myDictionary

And then in Start()

    myDictionary = new Dictionary<int, GameObject>();

It’s not really necessary to do it in the ‘Start’ method.

The dictionary constructor just initializes an internal array. And it doesn’t touch the unity api. So no big deal.