简体   繁体   English

Func,C#,“= <>9__1”是什么意思?

[英]Func, C#, What does "= <>9__1" mean?

What does "<>9__1" mean in this piece of code?这段代码中的“<>9__1”是什么意思?

Func<string, int> selector;

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

This code does not compile.此代码无法编译。 It was decompiled from IL (Intermediate Language).它是从 IL(中间语言)反编译的。 IL has a more relaxed definition of valid identifiers than C#, so <>9__1 is a valid name in IL. IL 对有效标识符的定义比 C# 更宽松,因此<>9__1在 IL 中是一个有效名称。 Compiler-generated classes delegates methods and so on are intentionally given names that are invalid as C# identifiers.编译器生成的类委托方法等被故意指定为无效的名称作为 C# 标识符。 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.托管代码是用可以在 .NET 之上运行的高级语言之一编写的,例如 C#、Visual Basic、F# 等。 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另请参阅: .Net / CLR 标识符

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM