Skip to main content

Partial method must be declared within a partial class or partial struct

In This Article

CodeRush Classic shows the Partial method must be declared within a partial class or partial struct code issue if a partial method is declared within a non-partial class or struct.

#Fix

Make the method non-partial.

#Purpose

Highlights the partial method declarations, which would cause the A partial method must be declared within a partial class or partial struct compilation error.

#Example

public class MyClass
{
    partial void ProcessString(string text)
    {
        Console.WriteLine(text);
    }
}

Fix:

public class MyClass
{
    private void ProcessString(string text)
    {
        Console.WriteLine(text);
    }
}