InvalidCastException with .net datatypes but not with UnityEngine.Object

The following returns the following error:
Line 11: InvalidCastException: Cannot cast from source type to destination type.

It works perfectly with anything that inherits from UnityEngine.Object. I don’t understand how to prevent this from happening with .net datatypes.

void Start () {

        float[] f = new float[5];
        f[0] = 4.5f;
        Test(f);
	}

    void Test(object t)
    {
        if (t is Array)
        {
            Debug.Log("isarray");
            object[] a = (object[])t;
            if (a[0] is float)
            {
                Debug.Log("isfloat");
            }
        }
    }


            

Correct, float didn’t extends object.

You need te take a read about basic types, arrays and casting. Until you didn’t understand it is better to use a more complex collection like ArrayList. (1)

– Edited

I found the oficial docs about the problem, if you wish to get a deep understand