I'm learning TAP, and I'm wondering what feature of .NET allows the result in this method to be implicitly cast into or interpreted as a 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 to result, which is declared as a String?
Second, why can I say Return result though the return type is Task(Of String).