문제

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.

도움이 되었습니까?

해결책

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

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top