/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
docs/fundamentals/runtime-libraries/snippets/System/Boolean/Overview/vb/parse3.vb
27 строк
856 B
Genevieve Warren
Move member remarks (#39270)
30 янв 2024, 00:43
Не верифицирован
30 янв 2024, 00:43
6c88824
Код
Авторство
О чём код?
' Visual Basic .NET Document Option Strict On ' <Snippet9> Module Example8 Public Sub Main() Dim values() As String = {"09", "12.6", "0", "-13 "} For Each value In values Dim success, result As Boolean Dim number As Integer success = Int32.TryParse(value, number) If success Then ' The method throws no exceptions. result = Convert.ToBoolean(number) Console.WriteLine("Converted '{0}' to {1}", value, result) Else Console.WriteLine("Unable to convert '{0}'", value) End If Next End Sub End Module ' The example displays the following output: ' Converted '09' to True ' Unable to convert '12.6' ' Converted '0' to False ' Converted '-13 ' to True ' </Snippet9>