Why am I getting CS1056 Unexpected character '' in this code

I get the error of this unexpected character, and I do not understand why.

var list = new List<MyModel>();    
list.Add(new MyModel() {
    variable1 = 942,
    variable2 = 2001,
    variable3 = "my text",
    variable4   = 123
​}); // CS1056 Unexpected character ''  on this line
+9
source share
5 answers

From what the error says and the actual error code that I received from the online compiler after copying / pasting, your code in this line contains a character that does not appear, but the compiler is trying to interpret. Just try to erase every character starting with your closing bracket to your number 3 and press Enter again. It should work (this works for me).

+21
source

I just deleted the file Version=v4.0.AssemblyAttributes.cs(1,1,1,1)located in my temporary folder C:\Users\MyUser\AppData\Local\Tempand then it works fine.

.NET Core .NETCoreApp,Version=v2.1.AssemblyAttributes.cs

File to delete

+19

, .

0

. , (ASCII DLE, , -), . , notepad++ "View-> Symbol-> ". , , .

0

C:\Users\_\AppData\Local\Temp\ , , .

VS , .

0

Source: https://habr.com/ru/post/1599206/


All Articles