I am studying TAP , and I am wondering what feature of .NET allows you to use resultimplicitly in this method or interpret it as Task(Of String):
result
Task(Of String)
Public Async Function CheckHostInstructionAsync() As Task(Of String) Dim result As String result = Await pipeReader.ReadLineAsync() 'pipeReader is a System.IO.StreamReader If (result.Equals("exit", StringComparison.InvariantCultureIgnoreCase)) Then terminate = True Return result End Function
First, if Await pipeReader.ReadLineAsync()"returns" a Task(Of String), why can I assign it resultwhich is declared as String?
Await pipeReader.ReadLineAsync()
Secondly, why can I say the Return resultreturn type though Task(Of String).
Return result
TAP ( ) async-await, . async await. Task ( , ), , .
async-await
async
await
Task
pipeReader.ReadLineAsync() Task(Of String), String. await - , "" , .
pipeReader.ReadLineAsync()
String
result , , Task(Of String), String ( , )
Async/Await.
Async , , string, , , , .
Async
string
Await Async, , Task, - , , , , (a string ).
Await
Await pipeReader.ReadLineAsync() Task<string>, pipeReader.ReadLineAsync(). await ed, .
Task<string>
Secondly, returning a string from a method that should return Task<string>is done due to asyncdecoration, which tells the compiler to do this conversion for you.
Source: https://habr.com/ru/post/1568367/More articles:Minor JSON encoding issue on Android 4.1.2 - jsonSQL выбирает из нескольких таблиц на основе даты и времени - sqlHow to configure spring security for multiple servlets? - javaError "CERT_UNTRUSTED" in Atom - githubsubprocess stdin buffer not clearing on new line with bufsize = 1 - pythonГоризонтальный многопозиционный - cssSublime Text 3 Better Coffee Script Package - sublimetextWhy am I having a communication problem ... when I click the button in the user interface created after clicking on the link in the previous user interface? - javaIn firefox, when an element has a position and z-index, why change events do not fire on the tab? - javascriptOrganization and call of C # methods Dynamically - reflectionAll Articles