My bits to byte conversion works for selected items, for unselected items i am trying to make it unselected but the value is not changing.,
this is my piece of code.,
int count = SecurityGroups.Items.Count;
for (int index = 0; index < count; index++)
int arrayIndex = Convert.ToInt32(SecurityGroups.Items[index].Value);
if (SecurityGroups.Items[index].Selected)
//convert the bits to bytes
aGroup[arrayIndex / 8] |= (byte)(1 << (arrayIndex % 8));
aGroup[arrayIndex] = (byte)(0<< (arrayIndex % 8));

for unselected item the conversion part of making those byte to 0 fails. why is it
i tried making the bit to 0 but that as well does not work
aGroup[arrayIndex] = 0;

Re: Visual C# General Byte conversion fails

Matthew Watson


aGroup[arrayIndex] = (byte)(0<< (arrayIndex % 8));


aGroup[arrayIndex] &= ~(byte)(1<< (arrayIndex % 8));