/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
docs/fundamentals/runtime-libraries/snippets/System/InvalidOperationException/Overview/fsharp/Nullable2.fs
23 строки
649 B
Genevieve Warren
Remarks for exception types and Registry class (#38930)
03 янв 2024, 22:30
Не верифицирован
03 янв 2024, 22:30
932bcca
Код
Авторство
О чём код?
module Nullable2 // <Snippet5> open System open System.Linq let queryResult = [| Nullable 1; Nullable 2; Nullable(); Nullable 4 |] let numbers = queryResult.Select(fun nullableInt -> nullableInt.GetValueOrDefault()) // Display list using Nullable<int>.HasValue. for number in numbers do printf $"{number} " printfn "" let numbers2 = queryResult.Select(fun nullableInt -> if nullableInt.HasValue then nullableInt.Value else -1) // Display list using Nullable<int>.GetValueOrDefault. for number in numbers2 do printf $"{number} " printfn "" // The example displays the following output: // 1 2 0 4 // 1 2 -1 4 // </Snippet5>