相关疑难解决方法(0)

Task <int>如何成为一个int?

我们有这个方法:

async Task<int> AccessTheWebAsync()
{ 
    HttpClient client = new HttpClient();

   Task<string> getStringTask = client.GetStringAsync("http://msdn.microsoft.com");

   // You can do work here that doesn't rely on the string from GetStringAsync.
   DoIndependentWork();

   string urlContents = await getStringTask;
   //The thing is that this returns an int to a method that has a return type of Task<int>
   return urlContents.Length;
}
Run Code Online (Sandbox Code Playgroud)

之间是否隐式转换发生Task<int>int?如果没有,那么发生了什么?它是如何实现的?

.net c# asynchronous c#-5.0 .net-4.5

101
推荐指数
2
解决办法
9万
查看次数

标签 统计

.net ×1

.net-4.5 ×1

asynchronous ×1

c# ×1

c#-5.0 ×1