int count=0;
for( int i=0;i<buffer.Length;i++ )
   if( buffer[i]!=null ) count++;