Exception handling is discussed in Chapter 13, “Errors and Exceptions.” This is extremely similar among all three languages. All these languages use try/catch/finally for handling exceptions, and the throw keyword to create an exception:
// C# public void Method(Object o) { if (o == null) throw new ArgumentException("Error"); } public void Foo() { try { Method(null); } catch (ArgumentException ex) { } catch (Exception ex) { } finally { } } // C++/CLI public: void Method(Object^ o) { if (o == nullptr) throw gcnew ArgumentException("Error"); } void Foo() { try { Method(nullptr); } catch (ArgumentException^ ex) { } catch (Exception^ ex) { } finally { } } ' Visual Basic Public Sub Method(ByVal o As Object) If o = Nothing Then Throw New ArgumentException("Error") End Sub Public Sub Foo() Try Method(Nothing) Catch ex As ArgumentException ' Catch ex As Exception ' Finally ' End Try End Sub