Throw gcnew exception : throw « Statement « Visual C++ .NET






Throw gcnew exception

 
#include "stdafx.h"
using namespace System;

int main()
{

try
{
     bool error = true;
     // other code

     if (error)
     {
          throw gcnew Exception();
     }
}
catch( Exception^ exception)
{
      // code to handle the exception
}
}

   
  








Related examples in the same category

1.Rethrow Exception
2.Throw Derived Exception
3.Throw string as exception