コード例 #1
0
 public void WriteByteString(string s, int tag)
 {
     Reserve(10 + s.Length);
     byte[] by = HexUtil.HexStr2Bytes(s);
     if (by.Length > 255)
     {
         WriteHead(TarsStructBase.STRING4, tag);
         buf.WriteInt(by.Length);
         buf.WriteBytes(by);
     }
     else
     {
         WriteHead(TarsStructBase.STRING1, tag);
         buf.WriteByte(by.Length);
         buf.WriteBytes(by);
     }
 }
コード例 #2
0
 public void WriteStringByte(string s, int tag)
 {
     byte[] by = HexUtil.HexStr2Bytes(s);
     Reserve(10 + by.Length);
     if (by.Length > 255)
     {
         // 长度大于255,为String4类型
         WriteHead(TarsStructBase.STRING4, tag);
         buf.WriteInt(by.Length);
         buf.WriteBytes(by);
     }
     else
     {
         // 长度小于255,位String1类型
         WriteHead(TarsStructBase.STRING1, tag);
         buf.WriteByte(by.Length);
         buf.WriteBytes(by);
     }
 }