加入特定位

时间:2015-06-19 12:07:27

标签: c# .net bit-manipulation

我有两个属性Dataint Value对象int Width。 我有list<Data> DataList。 我有byte[] Result

我需要像这样处理这个列表:

foeach(var data in DataList)
{
     var byteData = BitConverter.GetBytes(data.Value); //result 4 bytes length a
     //Than i need to copy bits starting from hight (left) from byteData to Result, equal to data.Width.
     //So if DataList have 2 elements: DataList[0] with Value = 11101000 00000000 00000000 00000000 and Width = 5
     // and DataList[1] with Value = 11000111 11011000 00000000 00000000 and Width = 9

     //result should be 11101110 00111100
}

0 个答案:

没有答案