Студопедия — The MoveNext method
Студопедия Главная Случайная страница Обратная связь

Разделы: Автомобили Астрономия Биология География Дом и сад Другие языки Другое Информатика История Культура Литература Логика Математика Медицина Металлургия Механика Образование Охрана труда Педагогика Политика Право Психология Религия Риторика Социология Спорт Строительство Технология Туризм Физика Философия Финансы Химия Черчение Экология Экономика Электроника

The MoveNext method






The MoveNext method of an enumerator object encapsulates the code of an iterator block. Invoking the MoveNext method executes code in the iterator block and sets the Current property of the enumerator object as appropriate. The precise action performed by MoveNext depends on the state of the enumerator object when MoveNext is invoked:

· If the state of the enumerator object is before, invoking MoveNext:

o Changes the state to running.

o Initializes the parameters (including this) of the iterator block to the argument values and instance value saved when the enumerator object was initialized.

o Executes the iterator block from the beginning until execution is interrupted (as described below).

· If the state of the enumerator object is running, the result of invoking MoveNext is unspecified.

· If the state of the enumerator object is suspended, invoking MoveNext:

o Changes the state to running.

o Restores the values of all local variables and parameters (including this) to the values saved when execution of the iterator block was last suspended. Note that the contents of any objects referenced by these variables may have changed since the previous call to MoveNext.

o Resumes execution of the iterator block immediately following the yield return statement that caused the suspension of execution and continues until execution is interrupted (as described below).

· If the state of the enumerator object is after, invoking MoveNext returns false.

When MoveNext executes the iterator block, execution can be interrupted in four ways: By a yield return statement, by a yield break statement, by encountering the end of the iterator block, and by an exception being thrown and propagated out of the iterator block.

· When a yield return statement is encountered (§8.14):

o The expression given in the statement is evaluated, implicitly converted to the yield type, and assigned to the Current property of the enumerator object.

o Execution of the iterator body is suspended. The values of all local variables and parameters (including this) are saved, as is the location of this yield return statement. If the yield return statement is within one or more try blocks, the associated finally blocks are not executed at this time.

o The state of the enumerator object is changed to suspended.

o The MoveNext method returns true to its caller, indicating that the iteration successfully advanced to the next value.

· When a yield break statement is encountered (§8.14):

o If the yield break statement is within one or more try blocks, the associated finally blocks are executed.

o The state of the enumerator object is changed to after.

o The MoveNext method returns false to its caller, indicating that the iteration is complete.

· When the end of the iterator body is encountered:

o The state of the enumerator object is changed to after.

o The MoveNext method returns false to its caller, indicating that the iteration is complete.

· When an exception is thrown and propagated out of the iterator block:

o Appropriate finally blocks in the iterator body will have been executed by the exception propagation.

o The state of the enumerator object is changed to after.

o The exception propagation continues to the caller of the MoveNext method.







Дата добавления: 2015-09-07; просмотров: 431. Нарушение авторских прав; Мы поможем в написании вашей работы!



Композиция из абстрактных геометрических фигур Данная композиция состоит из линий, штриховки, абстрактных геометрических форм...

Важнейшие способы обработки и анализа рядов динамики Не во всех случаях эмпирические данные рядов динамики позволяют определить тенденцию изменения явления во времени...

ТЕОРЕТИЧЕСКАЯ МЕХАНИКА Статика является частью теоретической механики, изучающей условия, при ко­торых тело находится под действием заданной системы сил...

Теория усилителей. Схема Основная масса современных аналоговых и аналого-цифровых электронных устройств выполняется на специализированных микросхемах...

ТРАНСПОРТНАЯ ИММОБИЛИЗАЦИЯ   Под транспортной иммобилизацией понимают мероприятия, направленные на обеспечение покоя в поврежденном участке тела и близлежащих к нему суставах на период перевозки пострадавшего в лечебное учреждение...

Кишечный шов (Ламбера, Альберта, Шмидена, Матешука) Кишечный шов– это способ соединения кишечной стенки. В основе кишечного шва лежит принцип футлярного строения кишечной стенки...

Принципы резекции желудка по типу Бильрот 1, Бильрот 2; операция Гофмейстера-Финстерера. Гастрэктомия Резекция желудка – удаление части желудка: а) дистальная – удаляют 2/3 желудка б) проксимальная – удаляют 95% желудка. Показания...

ЛЕКАРСТВЕННЫЕ ФОРМЫ ДЛЯ ИНЪЕКЦИЙ К лекарственным формам для инъекций относятся водные, спиртовые и масляные растворы, суспензии, эмульсии, ново­галеновые препараты, жидкие органопрепараты и жидкие экс­тракты, а также порошки и таблетки для имплантации...

Тема 5. Организационная структура управления гостиницей 1. Виды организационно – управленческих структур. 2. Организационно – управленческая структура современного ТГК...

Методы прогнозирования национальной экономики, их особенности, классификация В настоящее время по оценке специалистов насчитывается свыше 150 различных методов прогнозирования, но на практике, в качестве основных используется около 20 методов...

Studopedia.info - Студопедия - 2014-2024 год . (0.012 сек.) русская версия | украинская версия