How do you apply a .net attribute to a return type

后端 未结 2 1363
庸人自扰
庸人自扰 2020-12-17 10:26

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

public ISomething Foo()
{
    return new MyFoo();
}
相关标签:
2条回答
  • 2020-12-17 11:16

    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();
    }
    
    0 讨论(0)
  • 2020-12-17 11:23
    [return:MarshalAs]
    public ISomething Foo()
    {
        return new MyFoo();
    }
    
    0 讨论(0)
提交回复
热议问题