Вопрос

What happens when a Exception is raised on a Try-Finally block (without catch) and another exception is raised on the Finally part?

Example:

Dim aux As String

Try
    Try
        aux.Split("."c)
    Finally
        aux = File.ReadAllText("")
    End Try
Catch ex As Exception
    Console.WriteLine(ex)
End Try
Это было полезно?

Решение

The last thrown exception is catched.

In this case, the ArgumentException from ReadAllText() on the Finally block. Ignoring the first exception being thrown.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top