Beispiel #1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="value">byte array.</param>
        public GXBitString(byte[] value)
        {
            StringBuilder sb = new StringBuilder();

            foreach (byte it in value)
            {
                GXCommon.ToBitString(sb, it, 8);
            }
            Value = sb.ToString();
        }
        public string asString()
        {
            if (Value == null)
            {
                return("");
            }
            StringBuilder sb = new StringBuilder(8 * Value.Length);

            foreach (byte it in Value)
            {
                GXCommon.ToBitString(sb, it, 8);
            }
            sb.Length = sb.Length - PadBits;
            return(sb.ToString());
        }
        public override sealed string ToString()
        {
            if (Value == null)
            {
                return("");
            }
            StringBuilder sb = new StringBuilder(8 * Value.Length);

            foreach (byte it in Value)
            {
                GXCommon.ToBitString(sb, it, 8);
            }
            sb.Length = sb.Length - PadBits;
            return(Convert.ToString((8 * Value.Length) - PadBits) + " bit " + sb.ToString());
        }
        /// <summary>
        /// Convert byte array to bit string.
        /// </summary>
        /// <param name="value">byte array.</param>
        /// <param name="index">Start index.</param>
        /// <param name="count">Count.</param>
        public static string ToBitString(byte[] value, int index, int count)
        {
            StringBuilder sb = new StringBuilder();

            foreach (byte it in value)
            {
                if (count < 1)
                {
                    break;
                }
                GXCommon.ToBitString(sb, it, count);
                count -= 8;
            }
            if (index != 0)
            {
                sb.Remove(0, index);
            }
            return(sb.ToString());
        }
Beispiel #5
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="value">byte array.</param>
        public GXBitString(byte[] value, int index, int count)
        {
            StringBuilder sb = new StringBuilder();

            foreach (byte it in value)
            {
                if (index != 0)
                {
                    --index;
                }
                else
                {
                    if (count < 1)
                    {
                        break;
                    }
                    GXCommon.ToBitString(sb, it, count);
                    count -= 8;
                }
            }
            Value = sb.ToString();
        }