Bonjour,
je m'essaye aux fonctions asynchrones
mon exemple est trés simple mais j'ai un message d'erreur :Je comprend bien que la fonction veut retourner un objet Task mais moi je veux retourner un stringImpossible de convertir implicitement le type 'string' en 'System.Threading.Tasks.Task<string>'
Mon codec'est le
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 using System; using System.Threading.Tasks; namespace async_and_await; class Program { Task<string> GetWebPageAsync() { string? s = "code html"; return s; //Impossible de convertir implicitement le type 'string' en 'System.Threading.Tasks.Task<string>' } async Task<string> Test() { string html = await GetWebPageAsync(); Console.WriteLine(html); return html; } static void Main(string[] args) { } }qui pose problemereturn s
Merci pour votre aide
Partager