ArgumentException Class : Exception System « Development « VB.Net






ArgumentException Class

 
Public Class App
    Public Shared Sub Main()
        Try 
            DivideByTwo(7)
        Catch Ex As ArgumentException
            Console.WriteLine(Ex)
        End Try
    End Sub

    Private Shared Function DivideByTwo(ByVal num As Integer) As Integer
        If ((num And 1)  = 1) Then
            Throw New ArgumentException("Number must be even", "num")
        End If
        Return (num / 2)
    End Function
End Class

   
  








Related examples in the same category

1.Use Argument ExceptionUse Argument Exception
2.Parse Number ExceptionParse Number Exception
3.OverflowException Class