I had a few detailed code:
private bool AnyUnselectedCombox() { bool anyUnselected = false; foreach (Control c in this.Controls) { if (c is ComboBox) { if ((c as ComboBox).SelectedIndex == -1) { anyUnselected = true; break; } } } return anyUnselected; }
... that Resharper proposed for elegance with a LINQ expression as follows:
return this.Controls.OfType<ComboBox>().Any(c => (c as ComboBox).SelectedIndex == -1);
... but a subsequent inspection of Resharper says about the code that it generated (above): “The cast type is redundant” (referring to the “c as ComboBox” part), so it ends up like:
return this.Controls.OfType<ComboBox>().Any(c => c.SelectedIndex == -1);
Should Resharper generate Resharper-approved code? Or is it just that sometimes it takes two passes to completely “dishonor your lower backs”?
source share