Export (0) Print
Expand All
Expand Minimize

Compiler Error CS0764

Visual Studio 2008

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.

// 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;
    }
}

Community Additions

ADD
Show:
© 2014 Microsoft