问题描述
大家好。
我将字节数组定义如下:
Hi All.
I define the byte array as below:
byte[] QsnC = new byte[120];
我想在循环中访问byte [n]和bit x设置并得到一点,怎么做最好的?
非常感谢
最好的问候......
我尝试了什么:
I wanna access to byte[n] and bit x in loop for set and get bit, How do best it ?
thanks a lot
Best Regards...
What I have tried:
for (int i = 1; i <= this.tb.Rows.Count; i++)
{
for (int Count = 1; Count <= 4; Count++)
{
if (Chk.Checked)
{
get_chk[i] = Chk.ID.Remove(0, 4);
}
}
}
输出:
get_chk [ 0]:1_1
get_chk [1]:1_2
,...
我想从QsnC [1]或位设置第1位2来自QsnC [2],如何在循环
Output:
get_chk[0]:1_1
get_chk[1]:1_2
,...
I wanna set bit 1 from QsnC[1] or bit 2 from QsnC[2] , How do it in loop
推荐答案
我想从QsnC [1]中设置第1位或从QsnC设置第2位[2],如何在循环中设置
I wanna set bit 1 from QsnC[1] or bit 2 from QsnC[2] , How do it in loop
这需要按位运算符<< ;
或>>
本文 [ ]将帮助您了解如何操作
That requires bitwise operators <<
or >>
This article Understand how bitwise operators work (C# and VB.NET examples)[^] will help you to understand how to do it
这篇关于如何从byte [x]访问位n?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!