简体   繁体   中英

Unexpected character error in C# while copy code from word file in visual studio 2019

Unexpected character error in C# while copy code from word file in visual studio 2019

i just copy a code from word file i use the same code in other visual studio versions and works fine

the problem i didn't found any errors

i followed some suggestions related to clean project - empty appdata but not worked

the code is very simple like this

public class Teacher 
‎{ 
‎    public int TeacherId { get; set; } 
‎    public string Code { get; set; } 
‎    public string Name { get; set; } 
‎} ‎
public class Student 
‎{ 
‎    public int StudentId { get; set; } 
‎    public string Code { get; set; } 
‎    public string Name { get; set; } 
‎    public string EnrollmentNo { get; set; } 
‎}‎

在此处输入图像描述

rewring the code manual takes time and also i want to know the reason as i didn't found any related reasons avaiable on my online search

in notepad when encod as ansi it shows like this在此处输入图像描述

appsetting json

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*"
}

@ Chris.

According to the description of the error and the actual error code obtained from the online compiler after copy/paste. Your code contains characters that is not visible but that the compiler is trying to interpret. You could try to delete all the spaces in the code and press Enter again (it did work for me),like the code in the picture below:

delete all the spaces in the code: 在此处输入图像描述 press Enter again:

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM