c# - IL Asm 函数名称中的 Unicode?

标签 c# .net unicode clr il

CLR 语言应该理解 Unicode,例如我可以在 C# 中定义一个名为 Δ(希腊三角洲)的函数。然而,当我在 IL Asm 中定义这样的函数时,编译器会提示非 ASCII 符号。这个问题有什么解决办法吗?

最佳答案

IL 中的方法名称需要用单引号 括起来。例如代码:

class Class1
{
   public void \u0394() // Greek Delta
   {
      return;
   }
}

...将编译成:

.method public hidebysig instance void  'Δ'() cil managed
{
  // Code size       4 (0x4)
  .maxstack  8
  IL_0000:  nop
  IL_0001:  br.s       IL_0003
  IL_0003:  ret
} // end of method Class1::'Δ'

请注意上面 IL 中方法名称周围的单引号

幸运的是,Visual Studio 足够聪明,可以显示实际的 Unicode 字符,这很好:

enter image description here

让所有同事讨厌你的好方法!

参见 Spec获取更多信息。

关于c# - IL Asm 函数名称中的 Unicode?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19327644/

相关文章:

ios - 表情符号支持 NSAttributedString 属性(字距调整/段落样式)

c# - 从控制台应用程序 exe 在 DLL 中启动 WPF 应用程序

c# - 通过 WCF 以某种方式获取枚举描述 "generically"

c# - 唯一标识一 block 硬盘

c# - 为什么在 x64 版本上对 System.Numerics 函数进行断点编辑参数时会出现 FatalExecutionEngineError?

elasticsearch - ElasticSearch 是否支持 Unicode/Chinese?

python - 在 Python 3 中将异常转换为字符串

c# - 带有子类参数的函数

c# - 使用 sandcaSTLe 将示例代码放入文档中

c# - 使用 DrawString() 绘制细文本?