我有这个功能,最多可以获取 10 个项目作为输入列表
public async Task<KeyValuePair<string, bool>[]> PayCallSendSMS(List<SmsRequest> ListSms)
{
List<Task<KeyValuePair<string, bool>>> tasks = new List<Task<KeyValuePair<string, bool>>>();
foreach (SmsRequest sms in ListSms)
{
tasks.Add(Task.Run(() => SendSMS(sms)));
}
var result = await Task.WhenAll(tasks);
return result;
}
Run Code Online (Sandbox Code Playgroud)
在这个函数中,我await要下载一些 JSON,然后反序列化它。
public async Task<KeyValuePair<string, bool>> SendSMS(SmsRequest sms)
{
//some code
using (WebResponse response = webRequest.GetResponse())
{
using (Stream responseStream = response.GetResponseStream())
{
StreamReader rdr = new StreamReader(responseStream, Encoding.UTF8);
string Json = await rdr.ReadToEndAsync();
deserializedJsonDictionary = (Dictionary<string, object>)jsonSerializer.DeserializeObject(Json);
}
}
//some code
return …Run Code Online (Sandbox Code Playgroud) 我的朋友和我正在争论这段小代码:
#include <stdio.h>
#include <stdio.h>
int foo (int k)
{
int i, n;
for (i = i ? 0 : i, n ^= n; i < sizeof(k) * 8;)
n += k >> i++ & ~-2;
return n;
}
Run Code Online (Sandbox Code Playgroud)
我怀疑它不会被编译,因为它i是未初始化的,但我的朋友们认为它会.你怎么看?