Export (0) Print
Expand All
Expand Minimize

Compiler Error C2826

'operator' must be declared static

Methods must be declared as static if they implement a managed operator.

C2826 is only reachable using /clr:oldSyntax.

The following sample generates C2826:

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

__value struct M {
   M op_Addition(M m1, M m2) {   // C2826
   // try the following line instead
   // static M op_Addition(M m1, M m2) {
      return m1;
   }
};

Community Additions

ADD
Show:
© 2014 Microsoft