2015-05-04 158 views
0

我想用我自己的編譯器(的CodeDOM)編譯代碼,但像這樣的代碼:編譯代碼 - 錯誤CS1056「`」

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. 

回答

0

如果從

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 
0

的反引號應該從代碼被刪除。這是錯誤代碼暗示的。

他們可能被添加,因爲你從這個代碼示例系統的一部分過度逃脫。

+0

我們確定刪除該字符會起作用嗎?這應該如何寫: 'System.Threading.Tasks.Task \'1 [System.Threading.Tasks.VoidTaskResult]' –

+0

我將堅持這種觀點,因爲我很快瀏覽了文檔,並且沒有沒有把反作用看成是一個有效的角色。此外,錯誤代碼明確告訴你,它不期望在這些位置上的反引號字符。 – Makoto

+0

好吧,因爲代碼不是我寫的,就像這個變量是從'System.Reflection.PropertyInfo.PropertyType' –