foreach fills array with

I’m receiving a NullReferenceException from a foreach loop that is locating a series of sprites based on their tag. The loop is finding all of the present objects and incrementing the array appropriately. But it is only transferring the last of the found objects into the array. All the other sectors are being filled with null.

foreach(OTSprite go in temp){
			if(go.gameObject.tag=="building"){
				buildings=new OTSprite[i+1];
				buildingOrigin=new Vector2[i+1];
				buildings*=go;*

buildingOrigin_=buildings*.position;
buildings.position=beneathScreen;
i++;
}
}*_

You are re-affecting buildings and buildingOrigin at each loop, so at the end you only have the last iteration, with the information at the index temp.Length-1. Declare and initialize those two arrays before the loop.