public virtual byte[] Serialize()
{
int length = 0;
length = this.varLength == false ? this.value.Length : this.value.Length + 2;
byte[] resultBytes = new byte[length];
if (this.varLength)
{
// Fill 2 bytes with length
resultBytes[0] = (byte)((ushort)this.value.Length & 0x00FF);
resultBytes[1] = (byte)(((ushort)this.value.Length & 0xFF00) >> 8);
}
Array.Copy(this.value, 0, resultBytes, this.varLength == false ? 0 : 2, this.value.Length);
return resultBytes;
}