3

所以我是 C# 和 Vs Studio 的新手。我通过添加新课程和测试我能做什么来学习它。但是,今天似乎无论我做什么,当我创建一个新类时,它都不会链接到主文件。

例如,我将转到顶部的工具栏并导航到Project -> Add New Item -> Visual C# Class

我注意到我不再像以前那样在此窗口中命名文件的选项

窗户

从我上次执行此操作并尝试在项目中创建一个新文件并在更改类名称时复制/粘贴所有代码时,我目前有工作类,但仍然无法正常工作。

不知道发生了什么,因为我已经按照 YouTube 教程点击点击,但它仍然无法正常工作。

文件结构

下面是我的 VS 工作室的统计数据,自从我上次使用它和上次使用它以来我没有改变,创建 ac# 类没有这些问题。

Microsoft Visual Studio Community 2019
Version 16.9.4
VisualStudio.16.Release/16.9.4+31205.134
Microsoft .NET Framework
Version 4.8.04084

Installed Version: Community

ASP.NET and Web Tools 2019   16.9.693.2781
ASP.NET and Web Tools 2019

Azure App Service Tools v3.0.0   16.9.693.2781
Azure App Service Tools v3.0.0

C# Tools   3.9.0-6.21160.10+59eedc33d35754759994155ea2f4e1012a9951e3
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

IntelliCode Extension   1.0
IntelliCode Visual Studio Extension Detailed Info

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

NuGet Package Manager   5.9.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

ProjectServicesPackage Extension   1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

TypeScript Tools   16.0.30201.2001
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools   3.9.0-6.21160.10+59eedc33d35754759994155ea2f4e1012a9951e3
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools   16.9.0-beta.21102.9+7ce7132f1459095e635194d09d6f73265352029a
Microsoft Visual F# Tools

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio
4

1 回答 1

2

您的解决方案资源管理器位于“文件夹视图”中 - 它在该视图中的行为不同。要切换回常规视图,请单击解决方案资源管理器(带圆圈)中的“在解决方案和视图之间切换”图标,然后双击您的解决方案文件 (.sln):

在此处输入图像描述

在此处输入图像描述

返回解决方案视图后,您应该能够右键单击并添加项目以再次添加类文件,并在创建之前选择其名称。

于 2021-05-27T14:53:16.550 回答