public static string ToStringValue(UInt16 value) { byte[] bytes = UInt16Ex.ToBytes(value); string result = string.Empty; foreach (byte b in bytes) { result += (char)b; } return(result);// System.Text.Encoding.UTF8.GetString(bytes); }
public static UInt16 FromStringValue(string value) { if (value.IsNullOrEmpty() || value.Length < 2) { throw new Exception("value is to small to contain any value"); } byte[] bytes = new byte[2]; for (int i = 0; i < bytes.Length; i++) { bytes[i] = (byte)value[i]; } //byte[] bytes = System.Text.Encoding.UTF8.GetBytes(value); return(UInt16Ex.FromBytes(bytes)); }