Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

476
Visualizações
Why do I get an CS1056 Unexpected character '' on this code

I'm getting this unexpected character '' error and I don't 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
over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

From what the error says and the actual error code I got from an Online compiler after copy/pasting, Your code on this line contains a character that is not visible but that the compiler is trying to interpret. Simply try erase every character starting at your closing bracket towards your number 3 and press Enter again It should be working (it did work for me)

over 4 years ago · Santiago Trujillo Relatório

0

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

For .NET Core you have to delete .NETCoreApp,Version=v2.1.AssemblyAttributes.cs

File to delete

over 4 years ago · Santiago Trujillo Relatório

0

As mentioned by Daneau in the accepted answer, the problem is by a character that is not visible in the IDE.

Here are several solutions to find the invisible character with Notepad++.

Solutions 1: Show Symbol

  • Copy the code to Notepad++,
  • Select View -> Show Symbol -> Show All Characters

This can show invisible control characters.

Solutions 2: Convert to ANSI

  • Copy the code to Notepad++,
  • Select Encoding- > Convert to ANSI

This will convert the invisible character to ? if it is a none ANSI character.

Solutions 3: Remove none ASCII characters

  • Copy the code to Notepad++,
  • Open the Find window (Ctrl+F)
  • Select the Replace tab
  • in "Find what" write: [^\x00-\x7F]
  • Leave "Replace with" empty
  • In "Search Mode" select "Regular expression"
  • Find and remove the none ASCII characters

This will remove none ASCII characters.

Note: This can remove valid non ASCII characters (in strings and comments) so try to skip those if you have any.

Tip: Use HEX-Editor plugin

Use Notepad++ HEX-Editor plugin to see the binary code of text. Any character out of the range of 0x00 - 0x7F (0 - 127) is a non ASCII character and a suspect of being the problem.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda