public byte[] ToByte()
{
List<byte> result = new List<byte>();
//First four are for the Command
result.AddRange(BitConverter.GetBytes((int)cmdCommand));
//Add the length of the name
if (strName != null)
result.AddRange(BitConverter.GetBytes(strName.Length));
else
result.AddRange(BitConverter.GetBytes(0));
//Length of the message
if (strMessage != null)
result.AddRange(BitConverter.GetBytes(strMessage.Length+100));
else
result.AddRange(BitConverter.GetBytes(0));
//Add the name
if (strName != null)
result.AddRange(Encoding.GetEncoding(936).GetBytes(strName));
//And, lastly we add the message text to our array of bytes
if (strMessage != null)
// result.AddRange(Encoding.GetEncoding("gb2312").GetBytes(strMessage));
result.AddRange(Encoding.GetEncoding(936).GetBytes(strMessage+" "));
return result.ToArray();
}