如何申请一个.NET属性返回类型 [英] How do you apply a .net attribute to a return type
本文介绍了如何申请一个.NET属性返回类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何申请的MarshalAsAttribute以低于code中的返回类型?
公共ISomething富()
{
返回新MyFoo();
}
解决方案
据<一href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshalasattribute.aspx">http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshalasattribute.aspx:
[返回:的MarshalAs(&lt;您的名帅型&GT;)
公共ISomething美孚()
{
返回新MyFoo();
}
How do I apply the MarshalAsAttribute to the return type of the code below?
public ISomething Foo()
{
return new MyFoo();
}
解决方案
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();
}
这篇关于如何申请一个.NET属性返回类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文