Cast your int to byte:
Int32 hex = 0xA1;
byte[] connect = new byte[] { 0x00, 0x21, 0x60, 0x1F, 0xA1, (byte)hex};
Or define it as byte to begin with:
byte hex = 0xA1;
byte[] connect = new byte[] { 0x00, 0x21, 0x60, 0x1F, 0xA1, hex};
String to byte conversion:
static byte hexstr2byte(string s)
{
if (!s.StartsWith("0x") || s.Length != 4)
throw new FormatException();
return byte.Parse(s.Substring(2), System.Globalization.NumberStyles.HexNumber);
}
As you can see, .NET formatting supports hexa digits, but not the "0x" prefix. It would be easier to omit that part altogether, but your question isn't exactly clear about that.