mscorlib 4.0.0.0 System.Runtime.CompilerServices.StateMachineAttribute System.AttributeUsage(System.AttributeTargets.Method, Inherited=false)

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#.

Indicates whether a method in Visual Basic is marked with the Iterator modifier.

- Constructor
  4.0.0.0
  To be added.

  Initializes a new instance of the class.

  The type object for the underlying state machine type that's used to implement a state machine method.