How to find if index in an array is empty?

I created an array that uses spritespublic Sprite[] UI_buildings but I want to check if an index is empty. I tried

public void AddBuildingSprites()
 {
     int alreadyDone = 0;
     foreach (GameObject a in UI_elements)
     {
         
         if (a.tag == "ImageHolder")
         {
             //Pierwszy sprite to page, ostatni 6*page-1, przy drugim page: ((page-1)*6), ostatni page*6-1
             if (a.GetComponent<Image>().sprite = UI_buildings[((page - 1) * 6) + alreadyDone] != null)
             {
                 a.GetComponent<Image>().sprite = UI_buildings[((page - 1) * 6) + alreadyDone];
             } else
             {
                 a.GetComponent<Image>().color.WithAlpha(0);
             }
             
             alreadyDone++;
         }
     }
 }

but it doesn’t let me use != null so i don’t know what to do

Line 10 is using a single equal sign (=). That is assignment.

Comparison is a double equal sign (==)

If that’s not what is going on here, at least untangle those lines… a LOT. Get some temporary variables in there that mean something.

If you have more than one or two dots (.) in a single statement, you’re just being mean to yourself.

Putting lots of code on one line DOES NOT make it any faster. That’s not how compiled code works.

The longer your lines of code are, the harder they will be for you to understand them.

How to break down hairy lines of code:

http://plbm.com/?p=248

Break it up, practice social distancing in your code, one thing per line please.

“Programming is hard enough without making it harder for ourselves.” - angrypenguin on Unity3D forums

“Combining a bunch of stuff into one line always feels satisfying, but it’s always a PITA to debug.” - StarManta on the Unity3D forums