【问题标题】:Compiling Code - error CS1056 '`'编译代码 - 错误 CS1056 '`'
【发布时间】:2015-05-04 14:21:34
【问题描述】:

我正在尝试使用我自己的编译器 (CodeDOM) 编译代码,但代码如下:

390.   sealed class FunctorComparer`1 {
421.   public System.Array+FunctorComparer`1[T] () {}
448.   abstract public interface IEnumerator`1 {
... (1676 matches) ...

我收到此错误:

c:\Users\[Username]\AppData\Local\Temp\0z4zag32.0.cs(390,29) : error CS1056: Unexpected character '`'

我错过了什么?


[EDIT (1, "16:25", "4 May")]
the code i m trying to compile is not written by me. I don't know what that
character stands for, learning it. But i found that on this site
http://submain.com/ghostdoc/samples/PowerCollections/HTML/html/75549028.htm
it is being used, and it is strange the CodeDOM doesnt parse it.

【问题讨论】:

    标签: codedom


    【解决方案1】:

    应该从代码中删除反引号。这就是错误代码所暗示的。

    它们可能是由于您从中获取此代码示例的系统部分过度转义而添加的。

    【讨论】:

    • 我们确定删除该字符会起作用吗?应该怎么写:System.Threading.Tasks.Task`1[System.Threading.Tasks.VoidTaskResult]
    • 我将坚持这种观点,因为我快速浏览了文档并没有将反引号视为有效字符。此外,错误代码明确告诉您它不希望在这些位置出现反引号字符。
    • 好吧,因为代码不是我写的,比如这个变量是从System.Reflection.PropertyInfo.PropertyType读取的
    【解决方案2】:

    任何成员(字段、属性、方法、类)的名称都不能包含字符

    '`'
    

    如果您正在阅读来自

    的详细信息
    System.Reflection
    

    它会添加这个字符,我不确定它是否需要,可能是因为它覆盖了一个虚拟成员 x 次。喜欢

    System.Threading.Tasks.Task`1[System.Threading.Tasks.VoidTaskResult] //1 time
    System.Threading.Tasks.Task`6[System.Threading.Tasks.VoidTaskResult] //6 times
    

    只需声明的第一部分就完成了,其中包含计算机完成工作所需的所有信息。

    from
    System.Threading.Tasks.Task`1[System.Threading.Tasks.VoidTaskResult]
    
    to
    System.Threading.Tasks.Task
    

    【讨论】:

      猜你喜欢
      • 2021-04-21
      • 2013-11-23
      • 2018-07-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-13
      • 2012-06-29
      相关资源
      最近更新 更多