Beispiel #1
0
        public static BitsBuilder operator +(BitsBuilder a, IBitsStorage b)
        {
            BitsBuilder c = new BitsBuilder();

            c.Append(a.GetCount, a.GetData);
            c.Append(b.GetCount, b.GetData);
            return(c);
        }
Beispiel #2
0
 public byte[] this[int start, int end]
 {
     get
     {
         BitsBuilder b = new BitsBuilder();
         for (int i = start; i < end; i++)
         {
             b.Append(1, this[i] ? (byte)0x1 : (byte)0x0);
         }
         return(b.ToBits().GetData);
     }
 }
Beispiel #3
0
        public static Bits FromBitString(string BitString)
        {
            BitsBuilder b = new BitsBuilder();

            foreach (char c in BitString)
            {
                if (c == '0')
                {
                    b.Append(1, 0);
                }
                else if (c == '1')
                {
                    b.Append(1, 1);
                }
                else
                {
                    throw new ArgumentException("Invalid bit string, can only contain 1's and 0's");
                }
            }
            return(b.ToBits());
        }