Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Unsafe code may not appear in iterators
The C# language specification does not allow unsafe code in iterators.
The following sample generates CS1629:
// CS1629.cs
// compile with: /unsafe
using System.Collections.Generic;
class C
{
IEnumerator<int> IteratorMeth() {
int i;
unsafe // CS1629
{
int *p = &i;
yield return *p;
}
}
}