Share via


Compiler Error CS0752

A partial method cannot have out parameters

A partial method cannot have an out parameter. Out parameters are not allowed because if the partial method is removed by the compiler then there is no guarantee that the out parameter is ever assigned.

To correct this error

  • Remove the out modifier from the parameter and use the return value of the method instead, or else remove the partial modifier from the method declaration.

Example

The following code generates CS0752:

// cs0752.cs
public partial class C
{
    partial void Part(out int num); // CS0752
    // try the following line instead
    // partial void Part(int num);

    public static int Main()
    {
        return 1;
    }
}

See Also

Reference

Partial Classes and Methods (C# Programming Guide)