Last active
October 21, 2018 10:55
-
-
Save mariusGundersen/f9df8e305e8eef6ba6d34ad30be93a64 to your computer and use it in GitHub Desktop.
duck-type-extensions-example1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Runtime.CompilerServices; | |
using System.Threading.Tasks; | |
// Example 1: await strings | |
public static TaskAwaiter<string> GetAwaiter(this string text) | |
=> Task.FromResult(text).GetAwaiter(); | |
// Now it doesn't complain when we await the string | |
await "Hello world"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment