Click here to Skip to main content
15,886,873 members
Home / Discussions / C#
   

C#

 
GeneralRe: How do you find value of bits in byte Pin
gwithey21-Jul-09 0:44
gwithey21-Jul-09 0:44 
AnswerRe: How do you find value of bits in byte Pin
monstale20-Jul-09 23:47
monstale20-Jul-09 23:47 
GeneralRe: How do you find value of bits in byte Pin
gwithey21-Jul-09 0:20
gwithey21-Jul-09 0:20 
GeneralRe: How do you find value of bits in byte Pin
monstale21-Jul-09 0:53
monstale21-Jul-09 0:53 
AnswerRe: How do you find value of bits in byte Pin
0x3c020-Jul-09 23:51
0x3c020-Jul-09 23:51 
AnswerRe: How do you find value of bits in byte Pin
DaveyM6921-Jul-09 2:01
professionalDaveyM6921-Jul-09 2:01 
GeneralRe: How do you find value of bits in byte Pin
PIEBALDconsult21-Jul-09 4:18
mvePIEBALDconsult21-Jul-09 4:18 
AnswerRe: How do you find value of bits in byte Pin
Luc Pattyn21-Jul-09 2:05
sitebuilderLuc Pattyn21-Jul-09 2:05 
Hi,

this code works like a bit getter on a byte array:
public static bool bitGetter(byte[] bytes, int index) {
    int byteNumber=index/8;
    int bitNumber=index%8;
    int bitMask=1<<bitNumber;
    int byt=bytes[byteNumber];
    int bit=byt&bitMask;
    if (bit==0) return false;
    return true;
}


and the condensed version is:

public static bool bitGetter(byte[] bytes, int index) {
    return 0!=bytes[index/8]&(1<<(index%8));
}


Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.

QuestionHow to find the needless references in a project ? Pin
chenxiang20-Jul-09 19:55
chenxiang20-Jul-09 19:55 
AnswerRe: How to find the needless references in a project ? Pin
stancrm20-Jul-09 20:41
stancrm20-Jul-09 20:41 
QuestionPlay Live Remote IP Cam Video in Windows application Player using C#.Net Pin
vasanth arivali20-Jul-09 19:02
vasanth arivali20-Jul-09 19:02 
AnswerRe: Play Live Remote IP Cam Video in Windows application Player using C#.Net Pin
Jimmanuel21-Jul-09 1:04
Jimmanuel21-Jul-09 1:04 
GeneralType conversion Pin
Mycroft Holmes20-Jul-09 16:46
professionalMycroft Holmes20-Jul-09 16:46 
GeneralRe: Type conversion Pin
harold aptroot20-Jul-09 16:53
harold aptroot20-Jul-09 16:53 
GeneralRe: Type conversion Pin
Mycroft Holmes20-Jul-09 18:11
professionalMycroft Holmes20-Jul-09 18:11 
GeneralRe: Type conversion PinPopular
PIEBALDconsult20-Jul-09 17:10
mvePIEBALDconsult20-Jul-09 17:10 
GeneralRe: Type conversion Pin
Mycroft Holmes20-Jul-09 18:09
professionalMycroft Holmes20-Jul-09 18:09 
GeneralRe: Type conversion Pin
PIEBALDconsult20-Jul-09 19:01
mvePIEBALDconsult20-Jul-09 19:01 
GeneralRe: Type conversion Pin
harold aptroot20-Jul-09 19:06
harold aptroot20-Jul-09 19:06 
GeneralRe: Type conversion Pin
PIEBALDconsult20-Jul-09 19:09
mvePIEBALDconsult20-Jul-09 19:09 
GeneralRe: Type conversion Pin
harold aptroot20-Jul-09 19:24
harold aptroot20-Jul-09 19:24 
QuestionMessage Removed Pin
20-Jul-09 14:19
ImNAM20-Jul-09 14:19 
AnswerRe: Getting Values from List Pin
PIEBALDconsult20-Jul-09 14:21
mvePIEBALDconsult20-Jul-09 14:21 
General[Message Deleted] Pin
ImNAM20-Jul-09 14:23
ImNAM20-Jul-09 14:23 
GeneralRe: Getting Values from List Pin
Christian Graus20-Jul-09 14:24
protectorChristian Graus20-Jul-09 14:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.