public static T ReadStruct <T>(this Stream Stream) where T : struct { var Size = Marshal.SizeOf(typeof(T)); var Buffer = new byte[Size]; Stream.Read(Buffer, 0, Size); return(StructUtils.BytesToStruct <T>(Buffer)); }
public static void WriteStruct <T>(this Stream Stream, T Object) where T : struct { byte[] Bytes = StructUtils.StructToBytes(Object); Stream.Write(Bytes, 0, Bytes.Length); }