如何将 .net 属性应用于返回类型 [英] How do you apply a .net attribute to a return type

查看:19
本文介绍了如何将 .net 属性应用于返回类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

public ISomething Foo()
{
    return new MyFoo();
}

推荐答案

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

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

这篇关于如何将 .net 属性应用于返回类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆