Check amount of elements in array

Hello,

In my script I have 3 options, the arrays contains 1, 2 or 3 elements (colors)
Is there a way to check the amount of elements in the array? I don’t mean the lenght of the array, I mean the amount of elements in the array. I do this to use it in a switch statement.

  public var colorArray = new Color[3];
    
    Function Update()
    {
    switch(// amount of variables in the array)
    {
    
    case 1 :
    // action 1
    break;
    
    case 2 :
    // action 2
    break;
    
    case 3 :
    // action 3
    break;

}
}

With a value type such as Color, the number of elements should equal the length of an array.

For reference types you can have nulls, but with a value such as Color, there should be as many elements as the length of the array.

int HowManyElementsAreInMyArray(object a) {
int ohyeahbaby = 0;
for (x = 0; x < a.GetUpperBounds[0]; x++) { // might have mispelled that
if (a != null) ohyeahbaby++;
}
return ohyeahbaby;
}