using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Text; namespace RCUHost.Protocols { /// /// 主机编号(房号) /// [StructLayoutAttribute(LayoutKind.Sequential, Pack = 1)] public struct HostNumber { /// /// 栋 /// public byte NBuild; /// /// 单元 /// public byte NUnit; /// /// 层 /// public byte NFloor; /// /// 房 /// public byte NRoom; /// /// 主机编码 /// /// public override string ToString() { return NBuild.ToString("000") + NUnit.ToString("000") + NFloor.ToString("000") + NRoom.ToString("000"); } /// /// 对应房号 /// /// public string ToRoomNumber() { return NFloor.ToString("000") + NRoom.ToString("000"); } /// /// 酒店编码 /// /// public Int64 ToHotelCode() { return Convert.ToInt64(Convert.ToInt16(NBuild.ToString("000")) + Convert.ToInt16(NUnit.ToString("000")) * 256); } } }