代码之家  ›  专栏  ›  技术社区  ›  user4833581

在visual studio 2019中从word文件复制代码时,C#中出现意外字符错误

  •  0
  • user4833581  · 技术社区  · 5 年前

    我在其他visualstudio版本中使用相同的代码,效果很好

    我遵循了一些与清理项目相关的建议-清空appdata但不起作用

    代码非常简单

    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; } 
    ‎}‎
    

    enter image description here

    重新编写代码手册需要时间,而且我想知道原因,因为我没有找到任何相关的原因,在我的网上搜索可用

    在记事本中,当编码为ansi时,它显示如下 enter image description here

    应用程序设置json

    {
      "Logging": {
        "LogLevel": {
          "Default": "Information",
          "Microsoft": "Warning",
          "Microsoft.Hosting.Lifetime": "Information"
        }
      },
      "AllowedHosts": "*"
    }
    
    0 回复  |  直到 5 年前
        1
  •  0
  •   Hui Liu-MSFT    5 年前

    @克里斯。

    根据错误描述和复制/粘贴后从联机编译器获得的实际错误代码。您的代码包含不可见的字符,但编译器正在尝试解释这些字符。您可以尝试删除代码中的所有空格,然后再次按Enter键(对我来说确实有效),如下图中的代码:

    enter image description here

    enter image description here