Click here to Skip to main content
16,020,459 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All.
I define the byte array as below:

C#
byte[] QsnC = new byte[120];


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:

C#
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);
		}
	}
}


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
Posted
Updated 9-Apr-16 1:20am
v5
Comments
Patrice T 9-Apr-16 7:15am    
Do you understand that you provide pieces of code unrelated to the question or not complete ?
And piece 1 and 2 are unrelated too.

1 solution

Quote:
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
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900