One of the really nice features I enjoy using in Resharper 4.0 is the refactoring that converts inefficient (and unpleasant to read) syntax into nice efficient code. In this post, I'll show some refactorings that Resharper (from JetBrains) gives us. There are lots more, but the ones listed below seem to come up the most in my own c# code.
From:
var url = wikiURL + "/api/AddPage?apikey_v1=" + apiKey + "&page=" + wikiPageName + "&name=" + name + "&email=" + email;
To:
var url = string.Format("{0}/api/AddPage?apikey_v1={1}&page={2}&name={3}&email={4}", wikiURL, apiKey, wikiPageName, name, email);
From:
if (ConfigurationManager.AppSettings["ShowDinnerConfirmation"].ToLower().Equals("true")) { TableRowSaturdayDinner.Visible = true; } else { TableRowSaturdayDinner.Visible = false; }
To:
TableRowSaturdayDinner.Visible = ConfigurationManager.AppSettings["ShowDinnerConfirmation"].ToLower().Equals("true");
From:
string s = context.Request.QueryString["Cache"] == null ? "true" : context.Request.QueryString["Cache"];
To:
string s = context.Request.QueryString["Cache"] ?? "true";