2007-03-28 Chris Toshok <toshok@ximian.com>
[mono-project.git] / mono / tests / marshal6.cs
blobfde486cd4afcf61b891dbe56762b339e06b9aec2
1 using System;
2 using System.Runtime.InteropServices;
5 [StructLayout(LayoutKind.Explicit, Size=32)]
6 public class Dummy {
7 [MarshalAs(UnmanagedType.ByValTStr, SizeConst=16)]
8 [FieldOffset(0)]
9 public string a;
12 public class X {
13 public static int Main () {
14 Dummy dummy = new Dummy ();
15 dummy.a = "abcd";
17 IntPtr p = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Dummy)));
18 Marshal.StructureToPtr(dummy, p, false);
20 if(Marshal.ReadByte(p, 0) != 0x61) {
21 return 1;
23 if(Marshal.ReadByte(p, 1) != 0x62) {
24 return 1;
26 if(Marshal.ReadByte(p, 2) != 0x63) {
27 return 1;
29 if(Marshal.ReadByte(p, 3) != 0x64) {
30 return 1;
32 return 0;