我在使用异步方法返回变量时遇到了问题。虽然代码可以执行,但无法返回电子邮件地址。
public async Task<string> GetSignInName (string id)
{
RestClient client = new RestClient("https://graph.windows.net/{tenant}/users");
RestRequest request = new RestRequest($"{id}");
request.AddParameter("api-version", "1.6");
request.AddHeader("Authorization", $"Bearer {token}");
//string emailAddress = await client.ExecuteAsync<rootUser>(request, callback);
var asyncHandler = client.ExecuteAsync<rootUser>(request, response =>
{
CallBack(response.Data.SignInNames);
});
return "test"; //should be a variable
}