Type cast is redundant > target-type conditional expression not available in C# 7.3, use 9+

Completed

In a asp.mvc project .NET framework 4.6.1 I'm getting a lot of resharper "Type cast is redundant" suggestions to remove cast.

When I remove the type cast, I get an error saying target-type conditional expression not available in C# 7.3, use 9+.

The "C# Language Level" of the project is set to "Experimental".

Can I suppress the resharper messages somehow? Or is there a better solution?

Upload id: 2021_07_10_Fxm9RCHrabAPFuzr (file: 2021-07-10_10-38-04.png)

 

 

5 comments
Comment actions Permalink

Hello,

 

Please specify what "C# Language Level" is set in Properties window (select the correspondent project and press F4 to open the window)? 

Thank you.

0
Comment actions Permalink

The "C# Language Level" of the project is set to "Experimental".

 

0
Comment actions Permalink

Could you please set it to Default and check if Type cast is redundant" suggestions still appear?

0
Comment actions Permalink

Setting  project property "C# Language Level" to "Default (autodetect)" removes the "Type cast is redundant" warnings/suggestions.

Not sure what other, if any, implications this change will have...

0
Comment actions Permalink

Hello,

 

thank you for letting me know.

"Default" value should be the one selected by default. Not sure why it switched to "Experimental" in your case.
Anyway, please feel free to contact us in case of any questions or problems.

0

Please sign in to leave a comment.