Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Interoperation the MarshalAs attribute

0 views
Skip to first unread message

Tony Johansson

unread,
Apr 26, 2010, 5:20:54 AM4/26/10
to
Hi!

If I have these three examples below. I just want to make sure that I have
understood this correct.
In the first example //Applied to a parameter. This will mean that the first
parameter if of type LPWStr because the
parameter msg is type converted to type LPWStr.

In the second example //Applied to a field within a class. This will mean
that the field msg is type converted to type LPWStr

In the third example //Applied to a return value. This will mean that the
returned type is type converted to type LPWStr

//Applied to a parameter.
public void M1 ([MarshalAs(UnmanagedType.LPWStr)]String msg);


//Applied to a field within a class.
class MsgText
{
[MarshalAs(UnmanagedType.LPWStr)] Public String msg;
}

//Applied to a return value.
[return: MarshalAs(UnmanagedType.LPWStr)]
public String GetMessage();

//Tony


0 new messages