如何将.net属性应用于返回类型

Kep*_*boy 17 .net c# attributes return-type

如何将MarshalAsAttribute应用于下面代码的返回类型?

public ISomething Foo()
{
    return new MyFoo();
}
Run Code Online (Sandbox Code Playgroud)

Fra*_*nov 38

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

[return: MarshalAs(<your marshal type>)]
public ISomething Foo()
{
    return new MyFoo();
}
Run Code Online (Sandbox Code Playgroud)