/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
docs/fundamentals/runtime-libraries/snippets/System/InvalidOperationException/Overview/fsharp/Nullable1.fs
21 строка
691 B
Genevieve Warren
Remarks for exception types and Registry class (#38930)
03 янв 2024, 22:30
Не верифицирован
03 янв 2024, 22:30
932bcca
Код
Авторство
О чём код?
module Nullable1 // <Snippet4> open System open System.Linq let queryResult = [| Nullable 1; Nullable 2; Nullable(); Nullable 4 |] let map = queryResult.Select(fun nullableInt -> nullableInt.Value) // Display list. for num in map do printf $"{num} " printfn "" // The example displays the following output: // 1 2 // Unhandled Exception: System.InvalidOperationException: Nullable object must have a value. // at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) // at Example.<Main>b__0(Nullable`1 nullableInt) // at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext() // at <StartupCode$fs>.main() // </Snippet4>