Skip to content

Instantly share code, notes, and snippets.

@mariusGundersen
Last active October 21, 2018 10:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mariusGundersen/f9df8e305e8eef6ba6d34ad30be93a64 to your computer and use it in GitHub Desktop.
Save mariusGundersen/f9df8e305e8eef6ba6d34ad30be93a64 to your computer and use it in GitHub Desktop.
duck-type-extensions-example1
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