| Re: Game Controller |
| Hi agnes.
This line converts each byte in the comByte array to a string. It first makes sure that the string is at least 2 characters and appends an extra zero to the end if it's not. Then, it makes sure that the string is at least 3 characters and appends an extra space to the end if it's not. The result would look something like this: A2 FF E1 ... However, there are other ways of doing it. Here are 2 other examples: public static string ByteToHex(byte[] comByte) { StringBuilder hex = new StringBuilder(comByte.Length * 2); foreach (byte data in comByte) hex.AppendFormat("{0:x2}", data); return hex.ToString(); } or public static string ByteToHex(byte[] comByte) { string hex = BitConverter.ToString(comByte); return hex.Replace("-",""); } |
| ProxyProdigy - December 31, 2009 10:50pm |
|
You must be logged in to post comments. Not a member? SIGN-UP NOW Registration is free and easy! |
Log In Already a member? Login here. |
