Thomas Levesque 6/21/2016

Pitfall: using var and async together

Read Original

The article details a common C# programming pitfall where using the 'var' keyword with an asynchronous method call (without an 'await') incorrectly stores a Task<T> instead of the result. This causes logical errors, as the Task is never null. It explores why compilers and analyzers miss it, suggests enabling nullable reference types in C# 8+, and emphasizes the importance of unit tests to catch such issues.

Pitfall: using var and async together

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser

Top of the Week