Exemplo n.º 1
0
        /// <summary>
        /// 10进制转换为16进制  不足4位会在前面补0
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static string Convert10To16(long value)
        {
            I3AnyRadixConvert anyConvert = new I3AnyRadixConvert();
            string            result     = anyConvert.X2X(value.ToString(), 10, 16);

            int ys = 0;

            Math.DivRem(result.Length, 4, out ys);
            ys = 4 - ys;

            for (int i = 1; i <= ys; i++)
            {
                result = "0" + result;
            }

            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 16进制转换为10进制
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static long Convert16To10(string value)
        {
            I3AnyRadixConvert anyConvert = new I3AnyRadixConvert();

            return(Convert.ToInt64(anyConvert.X2X(value, 16, 10)));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 10进制转换为8进制
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static string Convert10To8(long value)
        {
            I3AnyRadixConvert anyConvert = new I3AnyRadixConvert();

            return(anyConvert.X2X(value.ToString(), 10, 8));
        }