【问题标题】:Unexpected character error in C# while copy code from word file in visual studio 2019从 Visual Studio 2019 中的 Word 文件复制代码时 C# 中出现意外字符错误
【发布时间】:2021-05-18 10:32:01
【问题描述】:

在 Visual Studio 2019 中从 Word 文件复制代码时出现 C# 中的意外字符错误

我只是从word文件中复制一个代码 我在其他 Visual Studio 版本中使用相同的代码并且工作正常

我没有发现任何错误的问题

我遵循了一些与清理项目相关的建议 - 空 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; } 
‎}‎

重写代码手册需要时间,我也想知道原因,因为我没有在我的在线搜索中找到任何相关的原因

在记事本中编码为 ansi 时显示如下

应用设置 json

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

【问题讨论】:

  • 从这个主题复制代码本身会显示相同的错误,因此您可以在 Visual Studio 编辑器中尝试
  • 您介意分享您的 appsettings.json
  • 如果你从word复制到记事本然后从记事本复制到VS,你会遇到同样的问题吗?
  • 我在记事本中复制时更新帖子,因为 utf 仍然相同,但 ansi 代码显示奇怪的示例
  • 有一个字符 8206 是每一行的开头:codetable.net/decimal/8206。文档是从右到左的文档吗?也许将整个文档更改为从左到右

标签: c# visual-studio text visual-studio-2019 editor


【解决方案1】:

@克里斯。

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

删除代码中的所有空格: 再次按 Enter:

【讨论】:

  • 问题也与 microsoft word 本身有关 - 页面编码 - 当我用其他应用程序打开 word 文件时 - 问题已解决
猜你喜欢
  • 2021-08-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-11-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-22
相关资源
最近更新 更多