public int WriteBinary(byte[] buf, int ofs) { int p = 0; p += ProtoBuf.WriteVarInt(buf, ofs + p, (ulong)id); p += ProtoBuf.WriteVarInt(buf, ofs + p, ProtoBuf.UnsignedInt32(latCode)); p += ProtoBuf.WriteVarInt(buf, ofs + p, ProtoBuf.UnsignedInt32(lonCode)); p += ProtoBuf.WriteVarInt(buf, ofs + p, (uint)values.Length); foreach (var val in values) { p += ProtoBuf.WriteString(buf, ofs + p, val.Key); p += ProtoBuf.WriteString(buf, ofs + p, val.Value); } return(p); }