public static T BytesToGenericType <T>(byte[] bytes) where T : struct { var size = MarshalType <T> .Size; switch (MarshalType <T> .TypeCode) { case TypeCode.Object: if (MarshalType <T> .IsIntPtr) { switch (bytes.Length) { case 1: return((T)(object)new IntPtr(BitConverter.ToInt32(new byte[] { bytes[0], 0, 0, 0 }, 0))); case 2: return((T)(object)new IntPtr(BitConverter.ToInt32(new byte[] { bytes[0], bytes[1], 0, 0 }, 0))); case 4: return((T)(object)new IntPtr(BitConverter.ToInt32(bytes, 0))); case 8: return((T)(object)new IntPtr(BitConverter.ToInt64(bytes, 0))); } } break; case TypeCode.Boolean: return((T)(object)BitConverter.ToBoolean(bytes, 0)); case TypeCode.SByte: case TypeCode.Byte: return((T)(object)bytes[0]); case TypeCode.Int16: return((T)(object)BitConverter.ToInt16(bytes, 0)); case TypeCode.UInt16: return((T)(object)BitConverter.ToUInt16(bytes, 0)); case TypeCode.Int32: return((T)(object)BitConverter.ToInt32(bytes, 0)); case TypeCode.UInt32: return((T)(object)BitConverter.ToUInt32(bytes, 0)); case TypeCode.Int64: return((T)(object)BitConverter.ToInt64(bytes, 0)); case TypeCode.UInt64: return((T)(object)BitConverter.ToUInt64(bytes, 0)); case TypeCode.Single: return((T)(object)BitConverter.ToSingle(bytes, 0)); case TypeCode.Double: return((T)(object)BitConverter.ToDouble(bytes, 0)); } T generic = default; if (!MarshalType <T> .HasUnmanagedTypes) { var genericPtr = MarshalType <T> .GetPointer(ref generic); fixed(byte *bytesPtr = bytes) { NativeMethods.Copy(genericPtr, bytesPtr, size); return(generic); } } using (var memory = new LocalAllocation(size)) { memory.Write(bytes); generic = memory.Read <T>(); } return(generic); }
/// <summary> /// Unwrap object wrapped in <see cref="SerializedObjectWrapper"/> /// </summary> /// <param name="item"></param> /// <returns></returns> object Unwrap(SerializedObjectWrapper item) { if (item.Data.Array == null) { return(null); } if (item.Flags == RawDataFlag) { ArraySegment <byte> tmp = item.Data; if (tmp.Count == tmp.Array.Length) { return(tmp.Array); } // we should never arrive here, but it's better to be safe than sorry var retval = new byte[tmp.Count]; Array.Copy(tmp.Array, tmp.Offset, retval, 0, tmp.Count); return(retval); } var code = (TypeCode)(item.Flags & 0x00ff); byte[] data = item.Data.Array; int offset = item.Data.Offset; int count = item.Data.Count; switch (code) { // incrementing a non-existing key then getting it // returns as a string, but the flag will be 0 // so treat all 0 flagged items as string // this may help inter-client data management as well // // however we store 'null' as Empty + an empty array, // so this must special-cased for compatibilty with // earlier versions. we introduced DBNull as null marker in emc2.6 case TypeCode.Empty: return((data == null || count == 0) ? null : Encoding.UTF8.GetString(data, offset, count)); case TypeCode.DBNull: return(null); case TypeCode.String: return(Encoding.UTF8.GetString(data, offset, count)); case TypeCode.Boolean: return(BitConverter.ToBoolean(data, offset)); case TypeCode.Int16: return(BitConverter.ToInt16(data, offset)); case TypeCode.Int32: return(BitConverter.ToInt32(data, offset)); case TypeCode.Int64: return(BitConverter.ToInt64(data, offset)); case TypeCode.UInt16: return(BitConverter.ToUInt16(data, offset)); case TypeCode.UInt32: return(BitConverter.ToUInt32(data, offset)); case TypeCode.UInt64: return(BitConverter.ToUInt64(data, offset)); case TypeCode.Char: return(BitConverter.ToChar(data, offset)); case TypeCode.DateTime: return(DateTime.FromBinary(BitConverter.ToInt64(data, offset))); case TypeCode.Double: return(BitConverter.ToDouble(data, offset)); case TypeCode.Single: return(BitConverter.ToSingle(data, offset)); case TypeCode.Object: using (var ms = new MemoryStream(data, offset, count)) { #if NETCORE return(null); #else return(bf.Deserialize(ms)); #endif } default: throw new InvalidOperationException("Unknown TypeCode was returned: " + code); } }
/// <summary> /// Returns a Boolean value converted from one byte at a specified position in a byte array. /// </summary> /// <param name="value">An array of bytes.</param> /// <param name="startIndex">The starting position within value.</param> /// <returns>true if the byte at startIndex in value is nonzero; otherwise, false.</returns> public Boolean ToBoolean(Byte[] value, Int32 startIndex) { CheckByteArgument(value, startIndex, 1); return(BitConverter.ToBoolean(value, startIndex)); }
public virtual bool ReadBool(int pOffset) { return(BitConverter.ToBoolean(ReadMem(pOffset, 4), 0)); }
public virtual bool ReadBool(string module, int pOffset) { return(BitConverter.ToBoolean(ReadMem(DllImageAddress(module) + pOffset, 4), 0)); }
public bool GetBool(ref int position) { var bytes = GetBytes(ref position, sizeof(bool)); return(BitConverter.ToBoolean(bytes, 0)); }
public override SerializeStream GetBool(out bool outValue) { outValue = BitConverter.ToBoolean(Bytes.GetRange(Offset, sizeof(bool)).ToArray(), 0); Offset += sizeof(bool); return(this); }
// Token: 0x060000F1 RID: 241 RVA: 0x0000937C File Offset: 0x0000757C private static bool BytesToBool(byte[] bytes, int dataPosition) { return(BitConverter.ToBoolean(bytes, dataPosition)); }
private bool ReadBool(FileStream fs) { return(BitConverter.ToBoolean(ReadBytes(1, fs), 0)); }
public T Read <T>(IntPtr address) where T : struct { object ret = default(T); var buffer = new byte[0]; if (typeof(T) == typeof(string)) { return((T)(object)ReadCString(address)); } else { buffer = ReadBytes(address, (uint)Marshal.SizeOf(typeof(T))); } switch (Type.GetTypeCode(typeof(T))) { case TypeCode.Object: GCHandle handle = GCHandle.Alloc(buffer, GCHandleType.Pinned); Marshal.PtrToStructure(handle.AddrOfPinnedObject(), ret); handle.Free(); break; case TypeCode.Boolean: ret = BitConverter.ToBoolean(buffer, 0); break; case TypeCode.Char: ret = BitConverter.ToChar(buffer, 0); break; case TypeCode.Byte: ret = buffer[0]; break; case TypeCode.Int16: ret = BitConverter.ToInt16(buffer, 0); break; case TypeCode.UInt16: ret = BitConverter.ToUInt16(buffer, 0); break; case TypeCode.Int32: ret = BitConverter.ToInt32(buffer, 0); break; case TypeCode.UInt32: ret = BitConverter.ToUInt32(buffer, 0); break; case TypeCode.Int64: ret = BitConverter.ToInt64(buffer, 0); break; case TypeCode.UInt64: ret = BitConverter.ToUInt64(buffer, 0); break; case TypeCode.Single: ret = BitConverter.ToSingle(buffer, 0); break; case TypeCode.Double: ret = BitConverter.ToDouble(buffer, 0); break; default: throw new NotSupportedException($"Unknown type {typeof(T).Name}."); } return((T)ret); }
/// <summary> /// Reads a boolean from the stream. 1 byte is read. /// </summary> /// <returns>The boolean read</returns> public bool ReadBoolean() { ReadInternal(buffer, 1); return(BitConverter.ToBoolean(buffer, 0)); }
public static bool ToBool(byte[] data, int index) { return(BitConverter.ToBoolean(data, index)); }
public Boolean?GetBoolean(string key) { return(Get <Boolean?>(key, bytes => BitConverter.ToBoolean(bytes, 0))); }
/// <summary> /// The decompiler generates a literal (expression) on an expression. /// </summary> /// <param name="output">The output.</param> /// <param name="expression">The expression.</param> /// <param name="newLine">Indicates whether the expressions of the branch start on a new line.</param> /// <returns>Returns true if code was generated.</returns> private bool GenerateExpression(IndentedTextWriter output, ScriptExpression expression, bool newLine) { ScriptValueType type = _opcodes.GetTypeInfo(expression.ReturnType); ScriptValueType actualType = type; // Check if a typecast is occurring if (expression.Opcode != 0xFFFF) { actualType = _opcodes.GetTypeInfo(expression.Opcode); // Simply write the string for quoted expressions. if (actualType.Quoted) { // Don't quote the keyword none. if (expression.Value.IsNull || expression.StringValue == "none") { output.Write("none"); } else { output.Write("\"{0}\"", ScriptStringHelpers.Escape(expression.StringValue)); } return(false); } } uint value = GetValue(expression, actualType); byte[] val = BitConverter.GetBytes(value); string text; switch (actualType.Name) { case "void": text = ""; break; case "ai_command_script": case "script": short index = BitConverter.ToInt16(val, 0); text = _scripts.Scripts[index].Name; break; case "boolean": text = BitConverter.ToBoolean(val, 0) ? "true" : "false"; break; case "short": text = BitConverter.ToInt16(val, 0).ToString(); break; case "long": // Signed integer int signed = (int)value; text = signed.ToString(); break; case "real": float fl = BitConverter.ToSingle(val, 0); text = fl.ToString("0.0#######", CultureInfo.InvariantCulture); break; case "ai_line": text = expression.StringValue == "" ? "\"\"" : expression.StringValue; break; case "unit_seat_mapping": text = expression.Value.IsNull ? "none" : expression.StringValue; break; default: if (expression.Value.IsNull) { text = "none"; } else if (actualType.IsEnum) { string enumValue = actualType.GetEnumValue(value); if (enumValue != null) { text = enumValue; } else { throw new NotImplementedException("Unknown Enum Value."); } } else { //throw new NotImplementedException($"Unhandled Return Type: \"{actualType.Name}\"."); text = expression.StringValue; } break; } output.Write(text); HandleNewLine(output, newLine); return(false); }
public void Read(BinaryReader r) { x = r.ReadInt32(); y = r.ReadInt32(); fIsNull = BitConverter.ToBoolean(r.ReadBytes(1), 0); }
/// <summary> /// Reads a boolean from the stream. 1 byte is read. /// </summary> /// <returns>The boolean read</returns> public bool ReadBoolean() { this.ReadInternal(this.buffer, 1); return(BitConverter.ToBoolean(this.buffer, 0)); }
private void HandlePacket(byte type, byte[] payload) { List <byte> payloadList = new List <byte>(payload); switch (type) { case (byte)SCPackets.QUERY: if ((int)CurrentState % 8 == 0) { break; } int nameLength = payloadList.GetNextInt(); string name = Encoding.Unicode.GetString(payloadList.GetBytes(nameLength)); int maxOnline = payloadList.GetNextInt(); int online = payloadList.GetNextInt(); CurrentServer.Name = name; CurrentServer.MaxOnline = maxOnline; CurrentServer.Online = online; CurrentServer.Status = ServerStatus.ONLINE; ServerQueryReceived?.Invoke(this, new ServerQueryReceivedEventArgs() { Server = CurrentServer, Client = this }); break; case (byte)SCPackets.MESSAGE: if (CurrentState != ClientConnectionState.READY) { break; } bool broadcast = BitConverter.ToBoolean(payloadList.GetByteInByteCollection().CheckEndianness(), 0); int authorLength = payloadList.GetNextInt(); string author = Encoding.Unicode.GetString(payloadList.GetBytes(authorLength)); int messageLength = payloadList.GetNextInt(); string message = Encoding.Unicode.GetString(payloadList.GetBytes(messageLength)); SendMessage( (broadcast) ? MessageType.BROADCAST : MessageType.CHAT, message, author); break; case (byte)SCPackets.READY: if (CurrentState != ClientConnectionState.CONNECTED) { break; } CurrentState = ClientConnectionState.READY; ClientReady?.Invoke(this, EventArgs.Empty); break; case (byte)SCPackets.NOTIFICATION: if (CurrentState != ClientConnectionState.READY) { break; } MessageBoxIcon[] iconMap = new MessageBoxIcon[] { MessageBoxIcon.None, MessageBoxIcon.Information, MessageBoxIcon.Warning, MessageBoxIcon.Error, }; int level = payloadList.GetNextInt(); int contentLength = payloadList.GetNextInt(); string content = Encoding.Unicode.GetString(payloadList.GetBytes(contentLength)); if (level > 4) // invalid level { break; } SendMessage(new MessageEventArgs() { Content = content, Type = MessageType.NOTIFICATION, NotificationIcon = iconMap[level], Client = this, }); break; case (byte)SCPackets.DISCONNECT: Disconnect(false, "Server closed connection."); break; default: break; } }
private static object TagBoolean_ToType(byte[] value, EventArgs e) { return(BitConverter.ToBoolean(value, 0)); }
public static bool DecodeToBool(string input) { return(BitConverter.ToBoolean(Decode(input), 0)); }
public static bool DecodeResponseSuccess(byte[] data) { return(BitConverter.ToBoolean(data, 0)); }
public bool ReadBoolean(IntPtr address) { return(BitConverter.ToBoolean(ReadBytes(address, 1), 0)); }
private bool ReverseValue(bool value) { byte[] bytes = BitConverter.GetBytes(value); Array.Reverse(bytes); return(BitConverter.ToBoolean(bytes, 0)); }
public virtual bool ReadBool(bool addToImageAddress, int pOffset) { return(BitConverter.ToBoolean(ReadMem(pOffset, 4, addToImageAddress), 0)); }
public new bool GetValue() { return(BitConverter.ToBoolean(Value, 0)); }
public FBXProperty ReadProperty() { char caractere = ReadChar(); byte[] dataInBytes; switch (caractere) { //Simples case 'C': return(new FBXProperty(ReadBoolean())); case 'Y': return(new FBXProperty(ReadInt16())); case 'I': return(new FBXProperty(ReadInt32())); case 'L': return(new FBXProperty(ReadInt64())); //IEEE 754 case 'F': return(new FBXProperty(ReadSingle())); case 'D': return(new FBXProperty(ReadDouble())); //Complexos (Ahhhh eu n queria copiar tudo em todos, mas n sei como faria isso dentro de uma função ;-;) case 'b': dataInBytes = ReadDataArrayBytes(1); bool[] bools = new bool[dataInBytes.Length]; for (int index = 0; index < bools.Length; index++) { bools[index] = BitConverter.ToBoolean(dataInBytes, index); } return(new FBXProperty(bools)); case 'l': dataInBytes = ReadDataArrayBytes(1); long[] longs = new long[dataInBytes.Length / 8]; for (int index = 0; index < longs.Length; index++) { longs[index] = BitConverter.ToInt64(dataInBytes, index * 8); } return(new FBXProperty(longs)); case 'i': dataInBytes = ReadDataArrayBytes(1); int[] ints = new int[dataInBytes.Length / 4]; for (int index = 0; index < ints.Length; index++) { ints[index] = BitConverter.ToInt32(dataInBytes, index * 4); } return(new FBXProperty(ints)); case 'f': dataInBytes = ReadDataArrayBytes(1); float[] floats = new float[dataInBytes.Length / 4]; for (int index = 0; index < floats.Length; index++) { floats[index] = BitConverter.ToSingle(dataInBytes, index * 4); } return(new FBXProperty(floats)); case 'd': dataInBytes = ReadDataArrayBytes(1); double[] doubles = new double[dataInBytes.Length / 8]; for (int index = 0; index < doubles.Length; index++) { doubles[index] = BitConverter.ToDouble(dataInBytes, index * 8); } return(new FBXProperty(doubles)); //Tipos mais "exóticos" case 'S': dataInBytes = ReadBytes(checked ((int)ReadUInt32())); return(new FBXProperty(BitConverter.ToString(dataInBytes))); case 'R': //Raw Bytes return(new FBXProperty(ReadBytes(checked ((int)ReadUInt32())))); } throw new Exception("Nao foi possivel ler o tipo dessa propiedade, o char lido fora: " + caractere); }
/// <summary> /// Gets the boolean obect from a byte array /// </summary> public object DeSerialize(byte[] extensionData) { return(extensionData != null && BitConverter.ToBoolean(extensionData, 0)); }
/// <summary> /// 反序列化 /// </summary> /// <param name="type"></param> /// <param name="datas"></param> /// <param name="offset"></param> /// <returns></returns> private static object Deserialize(Type type, byte[] datas, ref int offset) { dynamic obj = null; var len = 0; byte[] data = null; len = BitConverter.ToInt32(datas, offset); offset += 4; if (len > 0) { data = new byte[len]; Buffer.BlockCopy(datas, offset, data, 0, len); offset += len; if (type == stringType) { obj = Encoding.UTF8.GetString(data); } else if (type == typeof(byte)) { obj = (data); } else if (type == typeof(bool)) { obj = (BitConverter.ToBoolean(data, 0)); } else if (type == typeof(short)) { obj = (BitConverter.ToInt16(data, 0)); } else if (type == typeof(int)) { obj = (BitConverter.ToInt32(data, 0)); } else if (type == typeof(long)) { obj = (BitConverter.ToInt64(data, 0)); } else if (type == typeof(float)) { obj = (BitConverter.ToSingle(data, 0)); } else if (type == typeof(double)) { obj = (BitConverter.ToDouble(data, 0)); } else if (type == typeof(decimal)) { obj = (BitConverter.ToDouble(data, 0)); } else if (type == typeof(DateTime)) { var dstr = Encoding.UTF8.GetString(data); var ticks = long.Parse(StringHelper.Substring(dstr, 2)); obj = (new DateTime(ticks)); } else if (type.BaseType == typeof(Enum)) { var numType = Enum.GetUnderlyingType(type); if (numType == typeof(byte)) { obj = Enum.ToObject(type, data[0]); } else if (numType == typeof(short)) { obj = Enum.ToObject(type, BitConverter.ToInt16(data, 0)); } else if (numType == typeof(int)) { obj = Enum.ToObject(type, BitConverter.ToInt32(data, 0)); } else { obj = Enum.ToObject(type, BitConverter.ToInt64(data, 0)); } } else if (type == typeof(byte[])) { obj = (byte[])data; } else if (type.IsGenericType) { if (TypeHelper.ListTypeStrs.Contains(type.Name)) { obj = DeserializeList(type, data); } else if (TypeHelper.DicTypeStrs.Contains(type.Name)) { obj = DeserializeDic(type, data); } else { obj = DeserializeClass(type, data); } } else if (type.IsClass) { obj = DeserializeClass(type, data); } else if (type.IsArray) { obj = DeserializeArray(type, data); } else { throw new RPCPamarsException("ParamsSerializeUtil.Deserialize 未定义的类型:" + type.ToString()); } } return(obj); }
public override void LoadFromStream(Stream AStream, HCStyle AStyle, ushort aFileVersion) { base.LoadFromStream(AStream, AStyle, aFileVersion); FItems.Clear(); string vText = ""; if (aFileVersion > 36) { if (aFileVersion > 40) { byte vByte = (byte)AStream.ReadByte(); FStatic = HC.IsOdd(vByte >> 7); FSaveItem = HC.IsOdd(vByte >> 6); } else { byte[] vBuffer = BitConverter.GetBytes(FSaveItem); AStream.Read(vBuffer, 0, vBuffer.Length); FSaveItem = BitConverter.ToBoolean(vBuffer, 0); } if (FSaveItem) { HC.HCLoadTextFromStream(AStream, ref vText, aFileVersion); string[] vStrings = vText.Split(new string[] { HC.sLineBreak }, StringSplitOptions.None); for (int i = 0; i < vStrings.Length; i++) { FItems.Add(new HCCbbItem(vStrings[i])); } vText = ""; HC.HCLoadTextFromStream(AStream, ref vText, aFileVersion); vStrings = vText.Split(new string[] { HC.sLineBreak }, StringSplitOptions.None); for (int i = 0; i < vStrings.Length; i++) { FItemValues.Add(new HCCbbItem(vStrings[i])); } } } else { HC.HCLoadTextFromStream(AStream, ref vText, aFileVersion); string[] vStrings = vText.Split(new string[] { HC.sLineBreak }, StringSplitOptions.None); for (int i = 0; i < vStrings.Length; i++) { FItems.Add(new HCCbbItem(vStrings[i])); } if ((FItems.Count > 0) && (aFileVersion > 35)) { vText = ""; HC.HCLoadTextFromStream(AStream, ref vText, aFileVersion); vStrings = vText.Split(new string[] { HC.sLineBreak }, StringSplitOptions.None); for (int i = 0; i < vStrings.Length; i++) { FItemValues.Add(new HCCbbItem(vStrings[i])); } } else { FItemValues.Clear(); } FSaveItem = FItems.Count > 0; } }
private Int32 UnpackList(Int32 bytePos) { ParamTypes listType = (ParamTypes)(_Data[bytePos++] & ~128); UInt16 listLength = BitConverter.ToUInt16(_Data, bytePos); bytePos += 2; switch (listType) { case ParamTypes.DOUBLE: { List <Double> returnList = new List <Double>(listLength); for (Int32 x = 0; x < listLength; x++) { returnList.Add(BitConverter.ToDouble(_Data, bytePos)); bytePos += 8; } _PacketObjects.Add(returnList); } break; case ParamTypes.FLOAT: { List <Single> returnList = new List <Single>(listLength); for (Int32 x = 0; x < listLength; x++) { returnList.Add(BitConverter.ToSingle(_Data, bytePos)); bytePos += 4; } _PacketObjects.Add(returnList); } break; case ParamTypes.INT32: { List <Int32> returnList = new List <Int32>(listLength); for (Int32 x = 0; x < listLength; x++) { returnList.Add(BitConverter.ToInt32(_Data, bytePos)); bytePos += 4; } _PacketObjects.Add(returnList); } break; case ParamTypes.BOOL: { List <Boolean> returnList = new List <Boolean>(listLength); for (Int32 x = 0; x < listLength; x++) { returnList.Add(BitConverter.ToBoolean(_Data, bytePos)); bytePos += 1; } _PacketObjects.Add(returnList); } break; case ParamTypes.INT64: { List <Int64> returnList = new List <Int64>(listLength); for (Int32 x = 0; x < listLength; x++) { returnList.Add(BitConverter.ToInt64(_Data, bytePos)); bytePos += 8; } _PacketObjects.Add(returnList); } break; case ParamTypes.UINT32: { List <UInt32> returnList = new List <UInt32>(listLength); for (Int32 x = 0; x < listLength; x++) { returnList.Add(BitConverter.ToUInt32(_Data, bytePos)); bytePos += 4; } _PacketObjects.Add(returnList); } break; case ParamTypes.UINT64: { List <UInt64> returnList = new List <UInt64>(listLength); for (Int32 x = 0; x < listLength; x++) { returnList.Add(BitConverter.ToUInt64(_Data, bytePos)); bytePos += 8; } _PacketObjects.Add(returnList); } break; case ParamTypes.INT16: { List <Int16> returnList = new List <Int16>(listLength); for (Int32 x = 0; x < listLength; x++) { returnList.Add(BitConverter.ToInt16(_Data, bytePos)); bytePos += 2; } _PacketObjects.Add(returnList); } break; case ParamTypes.DECIMAL: { List <Decimal> returnList = new List <Decimal>(listLength); for (Int32 x = 0; x < listLength; x++) { Int32[] bits = new Int32[4]; for (Int32 i = 0; i < 4; i++) { bits[i] = BitConverter.ToInt32(_Data, bytePos + (i * 4)); } returnList.Add(new Decimal(bits)); bytePos += 16; } _PacketObjects.Add(returnList); } break; case ParamTypes.UINT16: { List <UInt16> returnList = new List <UInt16>(listLength); for (Int32 x = 0; x < listLength; x++) { returnList.Add(BitConverter.ToUInt16(_Data, bytePos)); bytePos += 2; } _PacketObjects.Add(returnList); } break; case ParamTypes.BYTE_PACKET: break; case ParamTypes.UTF8_STRING: { List <String> returnList = new List <String>(listLength); for (Int32 x = 0; x < listLength; x++) { bytePos += 1; //skip type marker Byte[] data = new Byte[BitConverter.ToInt32(_Data, bytePos)]; bytePos += 4; Array.Copy(_Data, bytePos, data, 0, data.Length); returnList.Add(Encoding.UTF8.GetString(data, 0, data.Length)); bytePos += data.Length; } _PacketObjects.Add(returnList); } break; case ParamTypes.PACKET: break; case ParamTypes.TIMESPAN: break; case ParamTypes.DATETIME: break; case ParamTypes.GUID: break; default: throw new PacketCorruptException("An internal unpacking error occured, Unknown internal data type present"); } return(bytePos); }
private bool ToBool(byte[] val) { return(BitConverter.ToBoolean(val)); }