Click here to Skip to main content
15,907,001 members
Home / Discussions / C#
   

C#

 
AnswerRe: Reading registry keys Pin
RaviRanjanKr29-Dec-10 18:50
professionalRaviRanjanKr29-Dec-10 18:50 
AnswerRe: Reading registry keys Pin
Anil Kumar.Arvapalli29-Dec-10 20:44
Anil Kumar.Arvapalli29-Dec-10 20:44 
GeneralRe: Reading registry keys Pin
PIEBALDconsult30-Dec-10 2:24
mvePIEBALDconsult30-Dec-10 2:24 
AnswerRe: Reading registry keys Pin
Kevin Marois30-Dec-10 5:40
professionalKevin Marois30-Dec-10 5:40 
QuestionListView scroll while typing Pin
Figmo229-Dec-10 16:52
Figmo229-Dec-10 16:52 
QuestionHot to draw ellipse line intersection Pin
ferry24029-Dec-10 9:35
ferry24029-Dec-10 9:35 
AnswerRe: Hot to draw ellipse line intersection Pin
fjdiewornncalwe29-Dec-10 9:48
professionalfjdiewornncalwe29-Dec-10 9:48 
GeneralRe: Hot to draw ellipse line intersection Pin
ferry24029-Dec-10 10:33
ferry24029-Dec-10 10:33 
GeneralRe: Hot to draw ellipse line intersection Pin
fjdiewornncalwe29-Dec-10 10:49
professionalfjdiewornncalwe29-Dec-10 10:49 
QuestionWindows Phone 7 passing multiple items between pages Pin
Paul Harsent29-Dec-10 8:06
Paul Harsent29-Dec-10 8:06 
AnswerRe: Windows Phone 7 passing multiple items between pages Pin
Pete O'Hanlon29-Dec-10 9:09
mvePete O'Hanlon29-Dec-10 9:09 
GeneralRe: Windows Phone 7 passing multiple items between pages Pin
Paul Harsent29-Dec-10 10:47
Paul Harsent29-Dec-10 10:47 
GeneralRe: Windows Phone 7 passing multiple items between pages Pin
Pete O'Hanlon29-Dec-10 10:49
mvePete O'Hanlon29-Dec-10 10:49 
QuestionProblem with reading Bytes Pin
Honeyboy_2029-Dec-10 7:49
Honeyboy_2029-Dec-10 7:49 
AnswerRe: Problem with reading Bytes Pin
Honeyboy_2029-Dec-10 7:50
Honeyboy_2029-Dec-10 7:50 
GeneralRe: Problem with reading Bytes Pin
Richard MacCutchan29-Dec-10 9:23
mveRichard MacCutchan29-Dec-10 9:23 
GeneralRe: Problem with reading Bytes Pin
Luc Pattyn29-Dec-10 9:34
sitebuilderLuc Pattyn29-Dec-10 9:34 
AnswerRe: Problem with reading Bytes Pin
carbon_golem29-Dec-10 8:34
carbon_golem29-Dec-10 8:34 
GeneralRe: Problem with reading Bytes Pin
Honeyboy_2029-Dec-10 8:57
Honeyboy_2029-Dec-10 8:57 
GeneralRe: Problem with reading Bytes Pin
Henry Minute29-Dec-10 9:29
Henry Minute29-Dec-10 9:29 
GeneralRe: Problem with reading Bytes Pin
carbon_golem29-Dec-10 10:30
carbon_golem29-Dec-10 10:30 
AnswerRe: Problem with reading Bytes Pin
carbon_golem29-Dec-10 12:47
carbon_golem29-Dec-10 12:47 
1) The first 'for' loop does not use its indexer. You can easily change the 'for' loop to a 'foreach' loop and iterate through the bytes. This will simplify your code a little.

2) Do comparisons of bytes, don't convert to strings.

3) If you're working in hex numbers use hex numbers throughout your code, don't mix up number bases. This will make your code easier to understand.

4) Your logical comparisons should use the logical && operator and not the & operator. The & operator returns a bitwise operation resulting in a number, not true or false. They are VERY different.

5) You should always put magic numbers in your code as constants.
public const Byte StartDelimiter = 0x55;
You should never sprinkle those into code manually, you run a huge risk if you are forced to refactor your work. Not to mention that you may mistype one.

6) I would avoid doing tricks with your loop variable like incrementing/decrementing it inside your loop block unless it is absolutely necessary - which should be never.

7) Match your braces. Just because you don't necessarily have to put them in after an 'if' statement doesn't mean you shouldn't. IMHO.

8) Do yourself a favor and look up the State Machine design pattern, it works very well for these kinds of problems.

9) When I ran your program (with healthy fixups) I found that you presumed that every 0xCC,0xCC was an end delimiter. This, apparently, is a false presumption. CCCC appears in your third dataset as valid information, and should not be treated as a fencepost delimiter. fix that up and I think you should get valid results, or at least get you further along.

Regards,
"Simplicity carried to the extreme becomes elegance."
-Jon Franklin

GeneralRe: Problem with reading Bytes Pin
Roger Wright2-Jan-11 18:09
professionalRoger Wright2-Jan-11 18:09 
Questionchanging a table name in dataset Pin
Ramkithepower29-Dec-10 5:58
Ramkithepower29-Dec-10 5:58 
AnswerRe: changing a table name in dataset Pin
Sandesh M Patil29-Dec-10 6:06
Sandesh M Patil29-Dec-10 6:06 

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.