Longitud de la matriz no nula
public static <T> int getLength(T[] arr){
int count = 0;
for(T el : arr)
if (el != null)
++count;
return count;
}
// equivalently in pure C# :
public static int getUsedLength(string[] arr)
{
int count = 0;
for (int i = 0; i < arr.Length; i++)
{
if (arr[i] != null)
{
++count;
}
}
return count;
}
Powerful Penguin