Remove unnecessary cast (IDE0004)
|Title||Remove unnecessary cast|
|Subcategory||Unnecessary code rules|
|Applicable languages||C# and Visual Basic|
This rule flags unnecessary type cast. A cast expression is unnecessary if the code semantics would be identical with or without it. This rule has no associated code style option.
// Code with violations int v = (int)0; // Fixed code int v = 0;
' Code with violations Dim v As Integer = CType(0, Integer) ' Fixed code Dim v As Integer = 0