private static string[] GetStringsFromBytes(Encoding encoding, byte[] data)
        {
            ArgCheck.NotNull(nameof(encoding), encoding);
            ArgCheck.NotNullOrEmpty(nameof(data), data);

            var values = new List <string>();

            using (var ms = new MemoryStream(data))
            {
                using (var r = new BinaryReader(ms, encoding, true))
                {
                    for (var i = r.ReadInt32(); i > 0; --i)
                    {
                        if (r.ReadBoolean())
                        {
                            values.Add(r.ReadString());
                        }
                        else
                        {
                            values.Add(null);
                        }
                    }
                }
            }
            return(values.ToArray());
        }
        private static byte[] GetBytesFromStrings(Encoding encoding, string[] values)
        {
            ArgCheck.NotNull(nameof(encoding), encoding);
            ArgCheck.NotNullOrEmpty(nameof(values), values);

            using (var ms = new MemoryStream())
            {
                using (var w = new BinaryWriter(ms, encoding, true))
                {
                    w.Write(values.Length);
                    foreach (var v in values)
                    {
                        w.Write(v != null);
                        if (v != null)
                        {
                            w.Write(v);
                        }
                    }
                    w.Flush();
                }
                ms.Flush();
                return(ms.ToArray());
            }
        }