Click here to Skip to main content
15,897,273 members
Home / Discussions / C#
   

C#

 
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 
GeneralRe: changing a table name in dataset Pin
Ramkithepower29-Dec-10 22:52
Ramkithepower29-Dec-10 22:52 
GeneralRe: changing a table name in dataset Pin
Sandesh M Patil30-Dec-10 0:36
Sandesh M Patil30-Dec-10 0:36 
QuestionNot your normal timeout... Pin
Pualee29-Dec-10 4:15
Pualee29-Dec-10 4:15 
AnswerRe: Not your normal timeout... Pin
Ravi Sant29-Dec-10 4:25
Ravi Sant29-Dec-10 4:25 
AnswerRe: Not your normal timeout... Pin
Ravi Sant29-Dec-10 4:27
Ravi Sant29-Dec-10 4:27 
GeneralRe: Not your normal timeout... Pin
Pualee29-Dec-10 4:48
Pualee29-Dec-10 4:48 
GeneralRe: Not your normal timeout... Pin
Ravi Sant29-Dec-10 8:25
Ravi Sant29-Dec-10 8:25 
AnswerRe: Not your normal timeout... Pin
Dave Kreskowiak29-Dec-10 6:30
mveDave Kreskowiak29-Dec-10 6:30 
QuestionShare the App_Themes folder between multiple sites Pin
anderslundsgard29-Dec-10 4:14
anderslundsgard29-Dec-10 4:14 
AnswerRe: Share the App_Themes folder between multiple sites Pin
Ravi Sant29-Dec-10 4:33
Ravi Sant29-Dec-10 4:33 
GeneralRe: Share the App_Themes folder between multiple sites Pin
anderslundsgard29-Dec-10 18:28
anderslundsgard29-Dec-10 18:28 
AnswerRe: Share the App_Themes folder between multiple sites Pin
RaviRanjanKr29-Dec-10 6:22
professionalRaviRanjanKr29-Dec-10 6:22 
QuestionIs it possible to block access to a specific registry key? Pin
turbosupramk329-Dec-10 4:10
turbosupramk329-Dec-10 4:10 
AnswerRe: Is it possible to block access to a specific registry key? Pin
Ravi Sant29-Dec-10 4:36
Ravi Sant29-Dec-10 4:36 

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.