Compiler Error CS0764

Both partial method declarations must be unsafe or neither may be unsafe

A partial method consists of a defining declaration (signature) and an optional implementing declaration (body). If the defining declaration has the unsafe modifier, the implementing declaration must also have it. Conversely, if the implementing declaration has the unsafe modifier, the defining declaration must also.

To correct this error

  • Assuming that the defining declaration is correct, add or remove the unsafe modifier from the implementing declaration to match the defining declaration.

Example

// cs0764.cs
//  Compile with: /target:library /unsafe
public partial class C
{
    partial void Part();
    unsafe partial void Part() //CS0764
    {
    }

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

See Also

Reference

Partial Classes and Methods (C# Programming Guide)