Exemple #1
0
        /// <summary>
        /// 是否为0或null
        /// </summary>
        public static void IfNullOrZero(ValueType valueType, Boolean canZero)
        {
            var type = valueType.GetType();

            if (type.IsValueType && type.IsNumeric())
            {
                var flag = !canZero?valueType.CastTo(0.0) <= 0.0 : valueType.CastTo(0.0) < 0.0;

                if (flag)
                {
                    throw new ArgumentNullException("参数不能为0或null");
                }
            }
        }