This documentation is archived and is not being maintained.

14.1 throw

Visual Studio .NET 2003

The C++ throw expression is extended to throw a pointer to a __gc class.

Example

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

__gc struct G : System::Exception { int i; };

void f() {
   G * pG = new G;
   throw pG;
}

It follows that a value class can only be thrown when boxed.

Show: