This documentation is archived and is not being maintained.

Compiler Error C3631

'function': cannot overload managed events

A managed event cannot be overloaded.

The following sample generates C3631:

// C3631.cpp
// compile with: /clr
#using <mscorlib.dll>

public __gc struct S2 {
   __event void func1();   // C3631, delete second declaration of func1
   __event void func1(int);
};

/*
// if you comment out S2 and add S1 to the compilation,
// you will see additional examples of C3631
// remove one of the add_myE methods and one of the remove_myE methods
public __gc struct S1
{
   __delegate void del1();
   __delegate void del2();

   __event add_myE(del1*)
   {
      return 0;
   }
   
   __event remove_myE(del1*)
   {
      return 0;
   }
   
   __event add_myE(del2*)
   {
      return 0;
   }

   __event remove_myE(del2*)
   {
      return 0;
   }
};   // C3631
*/

int main()
{
}
Show: