CRR0026 - Unused member

  • 2 min to read

This analyzer detects members that are not used in code. Specify accessibility levels for these members in the CodeRush options dialog:

  • Open the Editor | C# (Visual Basic) | Code Analysis | Unused Code Analysis options page.
  • Specify accessibility levels for unused members. For example, set the public option and uncheck other options to allow CodeRush to detect unused public members only.

    RemoveQualifier

The following example demonstrates how the analyzer detects an unused public member:

RemoveQualifier

TIP

Use the Highlight unused code in editor check box in the Editor | C# (Visual Basic) | Code Analysis | General option page to enable or disable the highlighting of unused members in the code editor.

To fix this issue, perform one of the following actions:

  • Remove the public member declaration or add it to your program:
class Program {
    static private double a0 = 0.938229;
    static private double a1 = -0.726534;
    static private double a2 = 0.647538;
    static private double a3 = 0.382564;
    public static int Main() {
        string input;
        double x, y;
        while (true) {
            Console.Write("x = ");
            input = Console.ReadLine();
            try {
                x = Convert.ToDouble(input);
                y = a0 + a1 * x + a2 * Math.Pow(x, 2);
                Console.WriteLine($"a0 + a1 * x + a2 * x^2  + a3 * x^3 = {y}");
            }
            catch (FormatException) {
                break;
            }
        }
        return 0;
    }
}

or

  • Enable the Apply in Action or Apply on Save option for the Remove unused members cleanup rule and run Code Cleanup.