In C#, the is
type testing operator can be used to check if the run-time type of an object is compatible with a given type. If the object is not null, then the
is
operator performs a cast, and so performing another cast following the check result is redundant.
This can impact:
- Performance: Performing the type check and cast separately can lead to minor performance issues. While this might not be noticeable in small
applications, it can add up in larger, more complex systems.
- Readability: The code is less readable and less clean because it requires two lines (and two operations) to achieve something that could be
done in one.