/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
docs/fundamentals/runtime-libraries/snippets/System/InvalidOperationException/Overview/fsharp/Iterating1.fs
23 строки
718 B
Genevieve Warren
Remarks for exception types and Registry class (#38930)
03 янв 2024, 22:30
Не верифицирован
03 янв 2024, 22:30
932bcca
Код
Авторство
О чём код?
module Iterating1 // <Snippet1> open System let numbers = ResizeArray [| 1; 2; 3; 4; 5 |] for number in numbers do let square = Math.Pow(number, 2) |> int printfn $"{number}^{square}" printfn $"Adding {square} to the collection...\n" numbers.Add square // The example displays the following output: // 1^1 // Adding 1 to the collection... // // // Unhandled Exception: System.InvalidOperationException: Collection was modified // enumeration operation may not execute. // at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) // at System.Collections.Generic.List`1.Enumerator.MoveNextRare() // at <StartupCode$fs>.main() // </Snippet1>