How do you apply a .net attribute to a return type
Asked Answered
G

2

17

How do I apply the MarshalAsAttribute to the return type of the code below?

public ISomething Foo()
{
    return new MyFoo();
}
Graybill answered 25/9, 2008 at 4:19 Comment(0)
A
42

According to http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshalasattribute.aspx:

[return: MarshalAs(<your marshal type>)]
public ISomething Foo()
{
    return new MyFoo();
}
Apologist answered 25/9, 2008 at 4:24 Comment(0)
W
3
[return:MarshalAs]
public ISomething Foo()
{
    return new MyFoo();
}
Workaday answered 25/9, 2008 at 4:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.