Redundant cast

Here's code example:
Снимок.JPG
ReSharper shows "Type cast is redundant" at line Console.WriteLine((A)b1 == (A)b2);  but this isn't true. Operator here are static methods with different realization in classes A and B, so the strings
Console.WriteLine(b1 == b2);
and
Console.WriteLine((A)b1 == (A)b2);
produces different actions as you can see by running the code (cs file attached).



Attachment(s):
Program.cs.zip
2 comments
Comment actions Permalink

Hello Alex
     The problem here is that only one of the type casts is reduntant (but it's not important which one, so ReSharper highlights both). If you remove one of the casts, ReSharper will immediately stop highlighting the other one. Thank you!

Andrey Serebryansky

Senior Support Engineer

JetBrains, Inc

http://www.jetbrains.com

"Develop with pleasure!"

0
Comment actions Permalink

My mistake.
Thank you.

0

Please sign in to leave a comment.