Alex Rivera | Logout

How do I get the STX character of hex 02

Asked 2012-03-06T14:42:19.777
11

I have a device to which I'm trying to connect via a socket, and according to the manual, I need the "STX character of hex 02".

How can I do this using C#?

Edit
Report

1 Answer

15

Just a comment to GeoffM's answer (I don't have enough points to comment the proper way).

You should never embed STX (or other characters) that way using only two digits.

If the next character (after "\x02") was a valid hex digit, that would also be parsed and it would be a mess.

string s1 = "\x02End";
string s2 = "\x02" + "End";
string s3 = "\x0002End";

Here, s1 equals ".nd", since 2E is the dot character, while s2 and s3 equal STX + "End".

answered 2012-11-01T14:26:01.667

Your Answer