public override byte[] Encode() { List <byte> result = new List <byte>(); result.Add(ActualType); result.AddRange(ErrorCode.ToByteArray()); if (ActualType == 0x1c) { result.AddRange(FrameType.ToByteArray()); } if (string.IsNullOrWhiteSpace(ReasonPhrase) == false) { byte[] rpl = new VariableInteger((UInt64)ReasonPhrase.Length); result.AddRange(rpl); byte[] reasonPhrase = ByteUtilities.GetBytes(ReasonPhrase); result.AddRange(reasonPhrase); } return(result.ToArray()); }