Пример #1
0
        /// <summary>
        /// Create a new array, with a consecutive series of bits (up to 64) with defined values.
        /// All other bits are left at their default undefined state.
        /// </summary>
        /// <param name="numBits">Number of bits in the resulting array.</param>
        /// <param name="start">Zero-based index of least significant bit in bitfield.</param>
        /// <param name="end">Index of most significant bit in bitfield (inclusive).</param>
        /// <param name="value">
        /// Contains values of bits to be inserted. If the bitfield represents fewer than 64 bits,
        /// these bits are found in the least significant bits of 'value'.
        /// </param>
        /// <returns></returns>
        public static TristateBitArray LoadBitfieldValue(int numBits, int start, int end, ulong value)
        {
            Debug.Assert(numBits > 0 && start >= 0 &&
                         end < numBits && end >= start && (1 + end - start) <= 64);

            var tmp = new TristateBitArray(numBits);

            tmp.MergeBitfieldValue(start, end, value);
            return(tmp);
        }