Module throtemp
Public Class TempIsZeroException : Inherits ApplicationException
Public Sub New(ByVal msg As String)
MyBase.New(msg)
End Sub
End Class
Public Class temp
Dim tmp As Integer = 1
Sub showtmp()
If (tmp = 0) Then
Throw (New TempIsZeroException("zero temp found"))
Else
Console.WriteLine("temp:{0}", tmp)
End If
End Sub
End Class
Sub main()
Dim temp As temp = New temp()
Try
temp.showtmp()
Catch e As TempIsZeroException
Console.WriteLine("TempIsZeroException:{0}", e.Message)
End Try
Console.ReadKey()
End Sub
End Module
In the above code,why this class is required and what is the meaning of it?
Public Class TempIsZeroException : Inherits ApplicationException
Public Sub New(ByVal msg As String)
MyBase.New(msg)
End Sub
End Class