Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

Compiler Error C3730

'event': an event must have both an add and a remove method

When creating user-defined add and remove methods for an event, both add and remove need to be present.

C3730 is only reachable using /clr:oldSyntax.

The following sample generates C3730:

// C3730.cpp
// compile with: /clr:oldSyntax
#using <mscorlib.dll>
using namespace System;

public __delegate void MyDel();

__gc class EventSource
   MyDel *pE;

   __event void add_E(MyDel* p)   // C3730, uncomment remove_E to resolve
      pE = static_cast<MyDel*> (Delegate::Combine(pE, p));
   __event void remove_E(MyDel* p)
      pE = static_cast<MyDel*> (Delegate::Remove(pE, p));
   __event void raise_E()
      if (pE != 0)  pE->Invoke();

int main()

Community Additions

© 2015 Microsoft