AngryHacker AngryHacker - 18 hours ago 2
C# Question

Resharper refactoring to remove magic strings

Is there such a thing? Either as a part of the product or a plugin? I can't see to find it.

I want to go from:

public DataTable Fetch() {
return ExecuteDataTable(_ConnectionString, "pr_DetectAffectedOrderLines");
}


to:

private const string SP_DETECT_AFFECTED_ORDER_LINES="pr_DetectAffectedOrderLines";

public DataTable Fetch() {
return ExecuteDataTable(_ConnectionString, SP_DETECT_AFFECTED_ORDER_LINES);
}

Answer

ReSharper | Refactor This (Ctrl-Shift-R) | Introduce field, then select to introduce constant.