Skip to content

Instantly share code, notes, and snippets.

@mstyura
Last active October 22, 2015 08:43
Show Gist options
  • Save mstyura/d2b257c629e33f12adf4 to your computer and use it in GitHub Desktop.
Save mstyura/d2b257c629e33f12adf4 to your computer and use it in GitHub Desktop.
Why there is no warning or even compilation error?
using System.Threading.Tasks;
namespace AwaitAndElvis
{
class Program
{
static void Main(string[] args)
{
Run(null).Wait();
}
private static async Task Run(Program p)
{
var a = await p?.Async(); // <- NRE
}
public async Task<int> Async()
{
return 5;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment