我有以下方法,这是Google.Apis IDatastore的实现
https://developers.google.com/api-client-library/dotnet/guide/aaa_oauth#web_applications:
public Task<T> GetAsync<T>(string key)
{
var account = GetAccountById(key);
return account;
}
以上不起作用。我明白了:
无法将类型'Model.Account'隐式转换为'System.Threading.Tasks.Task'
所以我不确定如何归还account
。我认为这很简单,但我没有到达那里。
答案 0 :(得分:3)
我认为Task<T>
的正确实现类似于
public Task<T> GetAsync<T>(string key)
{
// Replace with actual logic
return Task.Factory.StartNew(() => default(T));
}
对于Account
public Task<Account> GetAsync(string key)
{
return Task.Factory.StartNew(() => GetAccountById(key));
}