Hi all,

I tried to compile some unsafe code using mcs, however I am getting
error CS0030: Cannot convert type 'void*' to 'FooStruct*'

However, when I am doing it on VS.NET, it compiles fine. Is there any implicit conversion done in MS compiler that mono doesn't do?

using System;

namespace IntPtr_Conv
{
struct FooStruct
{
int x;
}

class Class1
{
static void Main(string[] args)
{
IntPtr[] pArray = new IntPtr[1]{IntPtr.Zero};

unsafe
{
// works only in MS
FooStruct* s0 = (FooStruct*)(pArray[0]);

// works on both mcs and MS C#
FooStruct* s1 = (FooStruct*)(pArray[0].ToPointer());
}
}
}
}

Thanks

Arnold


Join Excite! - http://www.excite.com
The most personalized portal on the Web!

Reply via email to