コード例 #1
0
ファイル: marshal5.cs プロジェクト: Zman0169/mono
	public unsafe static int Main () 
	{
		string testString = "A small string";

		IntPtr udata = mono_test_byvalstr_gen();

		ByValStrStruct data = new ByValStrStruct();
		data.a = testString;

		Marshal.StructureToPtr(data, udata, false);

		int c = mono_test_byvalstr_check(udata, testString);
		if (c != 0)
			return 1;

		ByValStrStruct_Unicode a = new ByValStrStruct_Unicode ();
		a.flag = 0x1234abcd;
		a.a = "1234";
		c = mono_test_byvalstr_check_unicode (ref a, 1);
		if (c != 0)
			return 2;

		a.a = "12";
		c = mono_test_byvalstr_check_unicode (ref a, 2);
		if (c != 0)
			return 3;

		a.a = "1234567890";
		c = mono_test_byvalstr_check_unicode (ref a, 3);
		if (c != 0)
			return 4;

		return 0;
	}
コード例 #2
0
    public unsafe static int Main()
    {
        string testString = "A small string";

        IntPtr udata = mono_test_byvalstr_gen();

        ByValStrStruct data = new ByValStrStruct();

        data.a = testString;

        Marshal.StructureToPtr(data, udata, false);

        int c = mono_test_byvalstr_check(udata, testString);

        if (c != 0)
        {
            return(1);
        }

        ByValStrStruct_Unicode a = new ByValStrStruct_Unicode();

        a.flag = 0x1234abcd;
        a.a    = "1234";
        c      = mono_test_byvalstr_check_unicode(ref a, 1);
        if (c != 0)
        {
            return(2);
        }

        a.a = "12";
        c   = mono_test_byvalstr_check_unicode(ref a, 2);
        if (c != 0)
        {
            return(3);
        }

        a.a = "1234567890";
        c   = mono_test_byvalstr_check_unicode(ref a, 3);
        if (c != 0)
        {
            return(4);
        }

        return(0);
    }