Question

I'm reading Async in C# 5.0, and the section on the compiler transform contains this snippet:

public Task<int> AlexsMethod()
{
    <AlexsMethod>d__0 stateMachine = new <AlexsMethod>d__0();
    stateMachine.<>4__this = this;
    stateMachine.<>t__builder = AsyncTaskMethodBuilder<int>.Create();
    stateMachine.<>1__state = -1;
    stateMachine.<>t__builder.Start<<AlexsMethod>d__0>(ref stateMachine);
    return stateMachine.<>t__builder.Task;
}

There are two pieces of notation that are new to me. The first is <AlexsMethod>d__0. The second is stateMachine.<>4__this. Neither works when I try them myself, so I suspect it's for use by the compiler only. But I'm having trouble searching for more information on what is intended by this notation.

Was it helpful?

Solution

Unlike the brackets marking generics (e.g. Task<int>), they don't have special meaning. They're just what the compiler generates - identifiers that are valid in IL, but not in C#.

OTHER TIPS

When you use lambda expression, lambda expression is a anonymous method. But compiler need to give it a name, so these methods are generated by compiler, it is not readable for human.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top