Longitud de un arreglo anidado

La propiedad .Length de un arreglo devuelve la cantidad de elementos que contiene. Por ejemplo, el siguiente arreglo contiene 2 elementos:

new object[] { 1, new object[] { 2, 3 } }
// 2 elementos: el número 1 y el arreglo new object[] { 2, 3 }

Supongamos que queremos saber el número total de elementos no anidados del arreglo. En este caso, new object[] { 1, new object[] { 2, 3 } } contiene 3 elementos no anidados: 1, 2 y 3.

Escribe Program.GetLength que devuelva el número total de elementos no anidados de un arreglo anidado.

Ejemplos

Program.GetLength(new object[] { 1, new object[] { 2, 3 } }) ➞ 3

Program.GetLength(new object[] { 1, new object[] { 2, new object[] { 3, 4 } } }) ➞ 4

Program.GetLength(new object[] { 1, new object[] { 2, new object[] { 3, new object[] { 4, new object[] { 5, 6 } } } } }) ➞ 6

Program.GetLength(new object[] { 1, new object[] { 2 }, 1, new object[] { 2 }, 1 }) ➞ 5

Notas

Un arreglo vacío debe devolver 0.