如何将.net属性应用于返回类型
时间:2020-03-06 14:42:13 来源:igfitidea点击:
如何将MarshalAsAttribute应用于以下代码的返回类型?
public ISomething Foo()
{
return new MyFoo();
}
解决方案
根据http://msdn.microsoft.com/zh-CN/library/system.runtime.interopservices.marshalasattribute.aspx:
[return: MarshalAs(<your marshal type>)]
public ISomething Foo()
{
return new MyFoo();
}
[return:MarshalAs]
public ISomething Foo()
{
return new MyFoo();
}

