public static byte[] ToBytes(this IConverter converter, object obj, ushort bufferSize = 1024) { var buffer = new byte[bufferSize]; var index = 0; converter.AddBytes(obj, buffer, ref index); var bytes = new byte[index]; Array.Copy(buffer, bytes, index); return(bytes); }