title | description | ms.date | ms.topic | ms.custom | author | ms.author | manager | ms.subservice |
---|---|---|---|---|---|---|---|---|
Add explicit cast |
Learn how to automatically add an explicit cast to an expression based on the context of your code. |
03/26/2020 |
reference |
ide-ref |
Mikejo5000 |
mikejo |
mijacobs |
general-ide |
This code generation applies to:
- C#
What: Lets you automatically add an explicit cast to an expression, based on usage.
When: You need to add an explicit cast to an expression and want to properly assign it automatically.
Why: You could add an explicit cast to an expression manually, however this feature adds it automatically based on the code context.
-
Place your caret on the error.
-
Press Ctrl+. to trigger the Quick Actions and Refactorings menu.
-
Select Add explicit cast.