title: C# Byte Array to struct
body: <p>I want to use ReadProcessMemory function to fill this struct.</p>
  
  <pre><code>    [StructLayout(LayoutKind.Explicit)]
  public struct WinMineGameStruct
  {
      [FieldOffset(0x118)]
      public Int32 xPressed;
      [FieldOffset(0x118)]
      public Int32 yPressed;
      [FieldOffset(0x140)]
      public Int32 MouseDown;
      [FieldOffset(0x160)]
      public Int32 GameStatus;
      [FieldOffset(0x164)]
      public Int32 IsInGame;
      [FieldOffset(0x194)]
      public Int32 MinesLeft;
      [FieldOffset(0x330)]
      public Int32 LevelMines;
      [FieldOffset(0x334)]
      public Int32 Colls;
      [FieldOffset(0x338)]
      public Int32 Rows;
      [FieldOffset(0x6a0)]
      public Int32 GameType;
      [FieldOffset(0x6cc)]
      public Int32 EasyBestScore;
      [FieldOffset(0x6d0)]
      public Int32 MediumBestScore;
      [FieldOffset(0x6d4)]
      public Int32 HardBestScore;
      [FieldOffset(0x6d8)]
      [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)]
      public Char[] PlayerEasyName;
      [FieldOffset(0x718)]
      [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)]
      public Char[] PlayerMediumName;
      [FieldOffset(0x758)]
      [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)]
      public Char[] PlayerHardName;
      [FieldOffset(0x798)]
      public Int32 NumLastHitDiscovered;
      [FieldOffset(0x79c)]
      public Int32 TimePlayed;
      [FieldOffset(0x7a4)]
      public Int32 DiscoveredFields;
  }
  </code></pre>
  
  <p>I know how to read byte array, int, string, short, and so on.
  I want to know how to convert byte array to this struct.</p>