//CONFORMING
public static UnaryExpression ArrayLength(Expression array)
{
ContractUtils.RequiresNotNull(array, "array");
if (!array.Type.IsArray || !typeof(Array).IsAssignableFrom(array.Type))
{
throw Error.ArgumentMustBeArray();
}
if (array.Type.GetArrayRank() != 1)
{
throw Error.ArgumentMustBeSingleDimensionalArrayType();
}
return(new UnaryExpression(ExpressionType.ArrayLength, array, typeof(int), null));
}