1 // Compiler options: -unsafe
4 using System
.Runtime
.InteropServices
;
8 [StructLayout (LayoutKind
.Explicit
)]
9 public unsafe struct Value
21 [StructLayout (LayoutKind
.Sequential
, Pack
= 4)]
22 public unsafe struct TValue
26 public TValue (long x
)
32 public override string ToString ()
34 return value.i
.ToString ();
38 public static unsafe int Main ()
40 TValue
[] values
= new TValue
[10];
41 values
[0] = new TValue (0L);
42 values
[1] = new TValue (1000L);
43 values
[2] = new TValue (1L);
44 Console
.WriteLine ("values: {0} {1} {2}", values
[0], values
[1], values
[2]);
45 fixed (TValue
* vals
= values
) {
46 Console
.WriteLine ("fixed: {0} {1} {2}", vals
[0], vals
[1], vals
[2]);
47 if (vals
[0].ToString () != "0")
50 if (vals
[1].ToString() != "1000")
53 if (vals
[2].ToString() != "1")
57 Console
.WriteLine ("ok");