-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReadInt64InStruct.cs
More file actions
34 lines (26 loc) · 784 Bytes
/
Copy pathReadInt64InStruct.cs
File metadata and controls
34 lines (26 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using System.Runtime.InteropServices;
public static class Program {
public struct StructWithInt64 {
public int A;
public Int64 B;
public int C;
public override string ToString () {
return String.Format("<A={0}, B={1}, C={2}>", A, B, C);
}
}
public static unsafe void Main (string[] args) {
var bytes = new byte[20] {
0x02, 0x00, 0x00, 0x00,
// Padding fill
0xFF, 0xFF, 0xFF, 0xFF,
0x02, 0x08, 0x00, 0x02,
0x12, 0x00, 0x60, 0x40,
0x00, 0x00, 0x60, 0x40
};
fixed (byte* pBytes = bytes) {
var pStruct = (StructWithInt64*)pBytes;
Console.WriteLine(*pStruct);
}
}
}