繁体   English   中英

.Net 4.5和4.0中Async方法的Out关键字的替换是什么?

[英]What is the replacement of Out keyword for Async methods in .Net 4.5 and 4.0?

所有我想在我的异步功能中使用Out关键字。 根据MSDN,Async修饰符不支持out关键字。 那么.Net framework 4.5 / 4.0中还有其他替代品吗?

您可以声明异步函数来返回Tuple 有了这个功能,该函数仍然能够返回多个值而不使用out参数。

public async Task<Tuple<string, int, bool>>SomeFunctionAsync()
{
    return new Tuple<string, int, bool>("foo", 0, false);
}

以供参考 :

更新:

您可以在评论中使用@svick建议的较短语法。 以下函数返回相同的值,但使用Tuple.Create

public async Task<Tuple<string, int, bool>>SomeFunctionAsync()
{
    return Tuple.Create("foo", 0, false);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM