Ryujinx/src/Ryujinx.Common/Extensions/BinaryReaderExtensions.cs
TSRBerry 2989c163a8
editorconfig: Set default encoding to UTF-8 (#5793)
* editorconfig: Add default charset

* Change file encoding from UTF-8-BOM to UTF-8
2023-12-04 14:17:13 +01:00

15 lines
376 B
C#

using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Ryujinx.Common
{
public static class BinaryReaderExtensions
{
public static T ReadStruct<T>(this BinaryReader reader) where T : unmanaged
{
return MemoryMarshal.Cast<byte, T>(reader.ReadBytes(Unsafe.SizeOf<T>()))[0];
}
}
}