A Quick Thank you and At-A-Program For Resharper and Refactoring

I had the following line embedded in an initializer:

EmailAlerts = String.IsNullOrEmpty(emailAlerts) ? false : emailAlerts.ToLower().Equals("true"),

Resharper says (“Simplify conditional operator”)

 

image

 

I say sure, ReSharper does

EmailAlerts = !String.IsNullOrEmpty(emailAlerts) && emailAlerts.ToLower().Equals("true"),

Clean, Elegant.  I’ve had some posts like this criticized in the past with comments like “Well, if you can’t do that on your own you shouldn’t be programming”.  My reply: “I could have, I didn’t, It did, and I like it better.

 

That’s it for now.

About Peter Kellner

Peter is a software professional specializing in mobile and web technologies. He has also been a Microsoft MVP for the past 7 years. To read more about Peter Kellner and his experience click here. For information about how Peter Kellner might be able to help you with your project click here.

Follow me:


Follow

Get every new post delivered to your Inbox

Join other followers: