See Also: IteratorStateMachineAttribute Members
You shouldn't apply the IteratorStateMachine attribute to methods in your code. For methods in Visual Basic that have the Iterator (Visual Basic) modifier, the compiler will apply the IteratorStateMachine attribute in the IL that it emits.
When a method (MethodName) in Visual Basic has the Iterator modifier, the compiler emits IL that includes a state machine structure. That structure contains the code in the method. That IL also contains a stub method (MethodName) that calls into the state machine. The compiler adds the IteratorStateMachine attribute to the stub method so that tools can identify the corresponding state machine. Details of the emitted IL might change in future releases of the compilers.
An iterator method performs a custom iteration over a collection by using the Yield (Visual Basic) statement to return each element one at a time. For more information, see Iterators (C# and Visual Basic).
You can't use IteratorStateMachineAttribute to test whether a method is an iterator method in C#.