A: 

It's just part of the C# spec:

26.1 Iterator blocks ... It is a compile-time error for an iterator block to contain an unsafe context (§27.1). An iterator block always defines a safe context, even when its declaration is nested in an unsafe context.

Presumably, the code that gets generated by the compiler needs to be verifiable in order to not have to be labelled 'unsafe'. If you want to use pointers, you'll have to implement IEnumerator yourself.

codekaizen
Thanks for your answer, but surely the usage of the fixed keyword is guaranteed that you are within the boundaries...??? like you're hardly going to trample something that is not belonging to your code...and it's readonly, so ...
tommieb75
@tommieb75: Not true, there are unverifiable side effects using pointers. Oh, Eric Lippert discusses this... off to read!
codekaizen
@CodeKaizen: Thanks! ;) Am reading it too and am pondering about it...
tommieb75
Eric's entire series on iterator blocks is a great resource! Scratch that - his entire blog is **awesome**.
Kevin Pullin
+3  A: 

Eric Lippert has an excellent blog post on this topic here: Iterator Blocks, Part Six: Why no unsafe code?

Kevin Pullin
+4  A: 

What I want to know is why you would use pointers for this at all. Why not simply say:

private IEnumerator<char> ReverseRead()
{
    int len = _str.Length;
    for(int i = 0; i < len; ++i)
        yield return _str[len - i - 1];
}

What's the compelling benefit of messing around with pointers?

Eric Lippert