You can cast your object to Array
object o = new int[3];
string test = (o as Array).Length.ToString();
MessageBox.Show(test);
or if it is a list:
object o = new List<int>(3);
string test = (o as IList).Count.ToString();
MessageBox.Show(test)
and you can combine both using the operator
is
if(o is IList) size = (o as IList).Count;
if(o is Array) size = (o as Array).Length;
Update:
After test,
int[]
is
IList
too, but the
List<int>
is not
Array
, you may use the
IList
in all case