Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Bits in a byte
Message
De
20/07/2005 11:28:36
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Divers
Thread ID:
01034269
Message ID:
01034276
Vues:
20
>Has anyone worked with the individual bits in a byte (System.Byte)?
>
>I need to construct a byte by setting the individual bits, and I also need to access the individual bits in a given byte.
>Any help would be welcome.
>
>Thanks,
>Einar

I haven't seen this specifically in .NET, but this is often achieved with bit-wise functions, like bitor, etc. (I don't know how this would be done in .NET; perhaps the operators like single vertical line for bitor, single ampersand for bitand, ...

bitand can be used to reset a bit (set it to zero), bitor to set it (set it to one), bitxor to switch a bit.

To read the value of an individual bit, you can also use bitor.

HTH,

Hilmar.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform