using System;
using System.Text;
public class Program
{
public static void Main()
string command = "<STX>01#DR#0#<ETX>";
byte[] bytes = Encoding.ASCII.GetBytes(command);
byte bcc = 0;
if (bytes != null && bytes.Length > 0) {
// Exclude SOH during BCC calculation
for (int i = 1; i < bytes.Length; i++) {
bcc ^= bytes[i];
}
foreach (byte b in bytes) {
Console.WriteLine(b);
Console.WriteLine(bcc);