Invalid "Type cast is redundant" warning?

Hi,

I sometimes use the conditional operator (?:) in C# like this:

IEnumerator it = ( someCondition
? new ClassOneEnumerator() as IEnumerator
: new ClassTwoEnumerator() as IEnumerator );

ReSharper (3.0.2) reports that both casts are redundant. But when I remove them, I get the "There is no explicit conversion" error.

Best,
Michal Blazejczyk

1 comment
Comment actions Permalink

File is re-analyzed after each change, so this should be counted not as
"both of them are redundant", but as "any of them is redundant"

--
Eugene Pasynkov
Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
"Michal Blazejczyk" <michal.blazejczyk@mail.mcgill.ca> wrote in message
news:18531957.1198088039772.JavaMail.itn@is.intellij.net...

Hi,

>

I sometimes use the conditional operator (?:) in C# like this:

>

IEnumerator it = ( someCondition
? new ClassOneEnumerator() as IEnumerator
: new ClassTwoEnumerator() as IEnumerator );

>

ReSharper (3.0.2) reports that both casts are redundant. But when I
remove them, I get the "There is no explicit conversion" error.

>

Best,
Michal Blazejczyk



0

Please sign in to leave a comment.