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

标签 c# .net attributes return-type

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

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();
}

关于c# - 如何将 .net 属性应用于返回类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/131456/

相关文章:

javascript - 如何防止后退按钮在 iframe 上工作?

c# - 尝试为所有 PDF 页面添加边框会引发 IO.Exception

c# - 在 C# 中如何使用 TcpClient 在远程 SSH 上运行 unix 命令

c# - 检查字符串中是否为根域

c# - 在 C# 中创建特定时区的 DateTime

Python 属性解析对于 xml :id 返回 None

c# - 需要一种干净的方式在 C# 中的两个执行线程之间进行握手

c# - 如何将文件链接到网站之外

c# - 无法解析 System.Drawing.Printing

java - 在 Java servlet 中,为什么只为上下文、请求和 session 范围定义属性?