Home > Software engineering >  Func, C#, What does "= <>9__1" mean?
Func, C#, What does "= <>9__1" mean?

Time:09-12

What does "<>9__1" mean in this piece of code?

Func<string, int> selector;

    if ((selector = <>9__1) == null)
    {
        selector = (<>9__1 = ((string unityBlendShapeName) => faceMesh.GetBlendShapeIndex(unityBlendShapeName)));
    }

CodePudding user response:

This code does not compile. It was decompiled from IL (Intermediate Language). IL has a more relaxed definition of valid identifiers than C#, so <>9__1 is a valid name in IL. Compiler-generated classes delegates methods and so on are intentionally given names that are invalid as C# identifiers. This ensures that the name does not conflict with identifiers in your code.

In What is "managed code"? Microsoft says:

Managed code is written in one of the high-level languages that can be run on top of .NET, such as C#, Visual Basic, F# and others. When you compile code written in those languages with their respective compiler, you don't get machine code. You get Intermediate Language code which the runtime then compiles and executes. [...]

See also: .Net / CLR Identifiers

  • Related