{"id":280,"date":"2023-10-18T22:57:32","date_gmt":"2023-10-18T14:57:32","guid":{"rendered":"https:\/\/miie.net\/?p=280"},"modified":"2023-10-18T22:57:32","modified_gmt":"2023-10-18T14:57:32","slug":"pro-c10-chapter-2-building-c-applications","status":"publish","type":"post","link":"https:\/\/diji.net\/?p=280","title":{"rendered":"Pro C#10 CHAPTER 2 Building C# Applications"},"content":{"rendered":"<h2>CHAPTER 2 Building C# Applications<\/h2>\n<p>\u6784\u5efa C# \u5e94\u7528\u7a0b\u5e8f<\/p>\n<h2>Building C# Applications<\/h2>\n<p>\u6784\u5efa C# \u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>As a C# programmer, you can choose from among numerous tools to build .NET Core applications. The tool (or tools) you select will be based primarily on three factors: any associated costs, the OS you are using to develop the software, and the computing platforms you are targeting. The point of this chapter is to provide the information you need to install the .NET 6 SDK and runtime and to present a first look at Microsoft\u2019s flagship IDEs, Visual Studio Code and Visual Studio.<br \/>\n\u4f5c\u4e3a C# \u7a0b\u5e8f\u5458\uff0c\u60a8\u53ef\u4ee5\u4ece\u4f17\u591a\u5de5\u5177\u4e2d\u8fdb\u884c\u9009\u62e9\u6765\u6784\u5efa .NET Core \u5e94\u7528\u7a0b\u5e8f\u3002\u60a8\u9009\u62e9\u7684\u5de5\u5177\u5c06\u4e3b\u8981\u57fa\u4e8e\u4e09\u4e2a\u56e0\u7d20\uff1a\u4efb\u4f55\u76f8\u5173\u6210\u672c\u3001\u7528\u4e8e\u5f00\u53d1\u8f6f\u4ef6\u7684\u64cd\u4f5c\u7cfb\u7edf\u4ee5\u53ca\u76ee\u6807\u8ba1\u7b97\u5e73\u53f0\u3002\u672c\u7ae0\u7684\u91cd\u70b9\u662f\u63d0\u4f9b\u5b89\u88c5 .NET 6 SDK \u548c\u8fd0\u884c\u65f6\u6240\u9700\u7684\u4fe1\u606f\uff0c\u5e76\u4ecb\u7ecdMicrosoft\u65d7\u8230 IDE\u3001Visual Studio Code \u548c Visual Studio\u3002<\/p>\n<p>The first part of this chapter will cover setting up your computer with the .NET 6 SDK and runtime.The next section will examine building your first C# application with Visual Studio Code and Visual Studio Community Edition.<br \/>\n\u672c\u7ae0\u7684\u7b2c\u4e00\u90e8\u5206\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 .NET 6 SDK \u548c\u8fd0\u884c\u65f6\u8bbe\u7f6e\u8ba1\u7b97\u673a\u3002\u4e0b\u4e00\u8282\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 Visual Studio Code \u548c Visual Studio Community Edition \u6784\u5efa\u60a8\u7684\u7b2c\u4e00\u4e2a C# \u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<blockquote><p>\n\u25a0 Note The screenshots in this and subsequent chapters are from Visual Studio Code v 1.61.2 or Visual Studio 2022 Community Edition v17.0.0 on Windows. If you want to build your applications on a different OS or IDE, this chapter will guide you in the right direction; however, the look and feel of your IDE might differ from the various screenshots in this text.<br \/>\n\u6ce8\u610f \u672c\u7ae0\u548c\u540e\u7eed\u7ae0\u8282\u4e2d\u7684\u5c4f\u5e55\u622a\u56fe\u6765\u81ea Windows \u4e0a\u7684 Visual Studio Code v 1.61.2 \u6216 Visual Studio 2022 Community Edition v17.0.0\u3002\u5982\u679c\u60a8\u60f3\u5728\u4e0d\u540c\u7684\u64cd\u4f5c\u7cfb\u7edf\u6216 IDE \u4e0a\u6784\u5efa\u5e94\u7528\u7a0b\u5e8f\uff0c\u672c\u7ae0\u5c06\u6307\u5bfc\u60a8\u671d\u7740\u6b63\u786e\u7684\u65b9\u5411\u524d\u8fdb;\u4f46\u662f\uff0cIDE \u7684\u5916\u89c2\u53ef\u80fd\u4e0e\u672c\u6587\u4e2d\u7684\u5404\u79cd\u5c4f\u5e55\u622a\u56fe\u4e0d\u540c\u3002\n<\/p><\/blockquote>\n<h2>Installing .NET 6<\/h2>\n<p>\u5b89\u88c5 .NET 6<\/p>\n<p>To get started developing applications with C# 10 and .NET 6 (on Windows, macOS, or Linux), the .NET 6 SDK needs to be installed (which also installs the .NET 6 runtime). All of the installs for .NET and .NET Core are located at the convenient www.dot.net. On the home page, click Download and then click \u201cAll .NET downloads\u201d under .NET. After clicking \u201cAll .NET downloads,\u201d you will see the LTS versions of .NET (6.0) and a link for .NET 6.0. Click \u201c.NET 6.0 (recommended).\u201d Once on that page, select the correct .NET 6 SDK for your operating system. For this book, you will need to install the SDK for .NET Core version 6.0.100 or higher, which also installs the .NET and ASP.NET Core runtimes. If you are using a Windows machine, it will also install the .NET Desktop runtime.<br \/>\n\u82e5\u8981\u5f00\u59cb\u4f7f\u7528 C# 10 \u548c .NET 6\uff08\u5728 Windows\u3001macOS \u6216 Linux \u4e0a\uff09\u5f00\u53d1\u5e94\u7528\u7a0b\u5e8f\uff0c\u9700\u8981\u5b89\u88c5 .NET 6 SDK\uff08\u540c\u65f6\u5b89\u88c5 .NET 6 \u8fd0\u884c\u65f6\uff09\u3002\u6240\u6709 .NET \u548c .NET Core \u7684\u5b89\u88c5\u90fd\u4f4d\u4e8e\u65b9\u4fbf\u7684 www.dot.net\u3002\u5728\u4e3b\u9875\u4e0a\uff0c\u5355\u51fb\u201c\u4e0b\u8f7d\u201d\uff0c\u7136\u540e\u5355\u51fb\u201c.NET\u201d\u4e0b\u7684\u201c\u6240\u6709 .NET \u4e0b\u8f7d\u201d\u3002\u5355\u51fb\u201c\u6240\u6709 .NET \u4e0b\u8f7d\u201d\u540e\uff0c\u60a8\u5c06\u770b\u5230 .NET \u7684 LTS \u7248\u672c \uff086.0\uff09 \u548c .NET 6.0 \u7684\u94fe\u63a5\u3002\u5355\u51fb\u201c.NET 6.0\uff08\u63a8\u8350\uff09\u201d\u3002\u8fdb\u5165\u8be5\u9875\u9762\u540e\uff0c\u4e3a\u64cd\u4f5c\u7cfb\u7edf\u9009\u62e9\u6b63\u786e\u7684 .NET 6 SDK\u3002\u5bf9\u4e8e\u672c\u4e66\uff0c\u4f60\u5c06\u9700\u8981\u5b89\u88c5\u9002\u7528\u4e8e .NET Core \u7684 SDK \u7248\u672c 6.0.100 \u6216\u66f4\u9ad8\u7248\u672c\uff0c\u8be5\u7248\u672c\u8fd8\u4f1a\u5b89\u88c5 .NET \u548c ASP.NET Core \u8fd0\u884c\u65f6\u3002\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662f Windows \u8ba1\u7b97\u673a\uff0c\u5b83\u8fd8\u5c06\u5b89\u88c5 .NET Desktop \u8fd0\u884c\u65f6\u3002<\/p>\n<h3>Understanding the .NET Version Numbering Scheme<\/h3>\n<p>\u4e86\u89e3 .NET \u7248\u672c\u7f16\u53f7\u65b9\u6848<\/p>\n<p>At the time of this writing, the .NET 6 SDK is at version 6.0.100. The first two numbers (6.0) indicate the highest version of the runtime you can target. In this case, that\u2019s 6.0. This means the SDK also supports developing for a lower version of the runtime, such as .NET 5 or .NET Core 3.1. The next number (1) is the quarterly feature band. Since we are currently in the first quarter of the year since the release, it is a 1. The final two numbers (00) indicate the patch version. This is a little bit clearer if you add a separator into the version in your mind and think of the current version as 6.0.1.00.<br \/>\n\u5728\u64b0\u5199\u672c\u6587\u65f6\uff0c.NET 6 SDK \u7684\u7248\u672c\u4e3a 6.0.100\u3002\u524d\u4e24\u4e2a\u6570\u5b57 \uff086.0\uff09 \u8868\u793a\u53ef\u4ee5\u9762\u5411\u7684\u6700\u9ad8\u8fd0\u884c\u65f6\u7248\u672c\u3002\u5728\u672c\u4f8b\u4e2d\uff0c\u8fd9\u662f 6.0\u3002\u8fd9\u610f\u5473\u7740 SDK \u8fd8\u652f\u6301\u9488\u5bf9\u8f83\u4f4e\u7248\u672c\u7684\u8fd0\u884c\u65f6\u8fdb\u884c\u5f00\u53d1\uff0c\u4f8b\u5982 .NET 5 \u6216 .NET Core 3.1\u3002\u4e0b\u4e00\u4e2a\u6570\u5b57 \uff081\uff09 \u662f\u5b63\u5ea6\u7279\u5f81\u5e26\u3002\u7531\u4e8e\u6211\u4eec\u76ee\u524d\u5904\u4e8e\u53d1\u5e03\u4ee5\u6765\u7684\u7b2c\u4e00\u5b63\u5ea6\uff0c\u56e0\u6b64\u5b83\u662f 1\u3002\u6700\u540e\u4e24\u4e2a\u6570\u5b57 \uff0800\uff09 \u8868\u793a\u4fee\u8865\u7a0b\u5e8f\u7248\u672c\u3002\u5982\u679c\u60a8\u5728\u8111\u6d77\u4e2d\u7684\u7248\u672c\u4e2d\u6dfb\u52a0\u5206\u9694\u7b26\u5e76\u5c06\u5f53\u524d\u7248\u672c\u89c6\u4e3a 6.0.1.00\uff0c\u8fd9\u4e00\u70b9\u4f1a\u66f4\u6e05\u695a\u4e00\u4e9b\u3002<\/p>\n<p>Confirming the .NET 6 Install\u786e\u8ba4 .NET 6 \u5b89\u88c5<br \/>\nTo confirm the installation of the SDK and the runtimes, open a command window and use the .NET command-line interface (CLI), dotnet.exe. The CLI has SDK options and commands available. The commands include creating, building, running, and publishing projects and solutions, and you will see examples of those commands later in this text. In this section, we will examine the SDK options, of which there are four, as shown in Table 2-1.<br \/>\n\u82e5\u8981\u786e\u8ba4 SDK \u7684\u5b89\u88c5\u548c\u8fd0\u884c\u65f6\uff0c\u8bf7\u6253\u5f00\u547d\u4ee4\u7a97\u53e3\u5e76\u4f7f\u7528 .NET \u547d\u4ee4\u884c\u754c\u9762 \uff08CLI\uff09 dotnet.exe\u3002CLI \u5177\u6709\u53ef\u7528\u7684\u5f00\u53d1\u5de5\u5177\u5305\u9009\u9879\u548c\u547d\u4ee4\u3002\u8fd9\u4e9b\u547d\u4ee4\u5305\u62ec\u521b\u5efa\u3001\u751f\u6210\u3001\u8fd0\u884c\u548c\u53d1\u5e03\u9879\u76ee\u548c\u89e3\u51b3\u65b9\u6848\uff0c\u672c\u6587\u540e\u9762\u5c06\u770b\u5230\u8fd9\u4e9b\u547d\u4ee4\u7684\u793a\u4f8b\u3002\u5728\u672c\u8282\u4e2d\uff0c\u6211\u4eec\u5c06\u68c0\u67e5 SDK \u9009\u9879\uff0c\u5176\u4e2d\u6709\u56db\u4e2a\u9009\u9879\uff0c\u5982\u8868 2-1 \u6240\u793a\u3002<\/p>\n<p>Table 2-1. .NET 5 CLI SDK Options<br \/>\n\u8868 2-1. .NET 5 \u547d\u4ee4\u884c\u754c\u9762\u5f00\u53d1\u5de5\u5177\u5305\u9009\u9879<\/p>\n<table>\n<tr>\n<th>Option\n<\/th>\n<th>Meaning in Life\n<\/th>\n<\/tr>\n<tr>\n<td>\n--version\n<\/td>\n<td>\nDisplay the .NET SDK version in use<br \/>\n\u663e\u793a\u6b63\u5728\u4f7f\u7528\u7684<br \/>\nNET SDK \u7248\u672c\n<\/td>\n<\/tr>\n<tr>\n<td>\n--info\n<\/td>\n<td>\nDisplay .NET information<br \/>\n\u663e\u793a .NET \u4fe1\u606f\n<\/td>\n<\/tr>\n<tr>\n<td>\n--list-runtimes\n<\/td>\n<td>\nDisplay the installed runtimes<br \/>\n\u663e\u793a\u5df2\u5b89\u88c5\u7684\u8fd0\u884c\u65f6\n<\/td>\n<\/tr>\n<tr>\n<td>\n--list-sdks\n<\/td>\n<td>\n Display the installed SDKs<br \/>\n \u663e\u793a\u5df2\u5b89\u88c5\u7684\u8f6f\u4ef6\u5f00\u53d1\u5de5\u5177\u5305\n<\/td>\n<\/tr>\n<\/table>\n<p>The --version option displays the highest version of the SDK installed on your machine, or the version specified in a global.json located at or above your current directory. Check the current version of the .NET SDK installed on your machine, enter the following:<br \/>\n-version \u9009\u9879\u663e\u793a\u8ba1\u7b97\u673a\u4e0a\u5b89\u88c5\u7684 SDK \u7684\u6700\u9ad8\u7248\u672c\uff0c\u6216\u5728\u5f53\u524d\u76ee\u5f55\u6216\u4e0a\u65b9\u7684 global.json \u4e2d\u6307\u5b9a\u7684\u7248\u672c\u3002\u68c0\u67e5\u8ba1\u7b97\u673a\u4e0a\u5b89\u88c5\u7684 .NET SDK \u7684\u5f53\u524d\u7248\u672c\uff0c\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndotnet --version\n<\/pre>\n<\/p>\n<p>For this book, the result needs to be 6.0.100 (or higher).<br \/>\n\u5bf9\u4e8e\u672c\u4e66\uff0c\u7ed3\u679c\u9700\u8981\u4e3a 6.0.100\uff08\u6216\u66f4\u9ad8\uff09\u3002<\/p>\n<p>To show all of the .NET Core Runtimes installed on your machine, enter the following:<br \/>\n\u82e5\u8981\u663e\u793a\u8ba1\u7b97\u673a\u4e0a\u5b89\u88c5\u7684\u6240\u6709 .NET Core \u8fd0\u884c\u65f6\uff0c\u8bf7\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<p><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndotnet --list-runtimes\n<\/pre>\n<\/p>\n<p>There are three different runtimes:<br \/>\n\u6709\u4e09\u79cd\u4e0d\u540c\u7684\u8fd0\u884c\u65f6\uff1a<\/p>\n<ul>\n<li>\nMicrosoft.AspNetCore.App (for building ASP.NET Core applications)<br \/>\nMicrosoft.AspNetCore.App\uff08\u7528\u4e8e\u6784\u5efa ASP.NET \u6838\u5fc3\u5e94\u7528\u7a0b\u5e8f\uff09\n<\/li>\n<li>\nMicrosoft.NETCore.App (the foundational runtime for .NET)<br \/>\nMicrosoft.NETCore.App\uff08.NET \u7684\u57fa\u7840\u8fd0\u884c\u65f6\uff09\n<\/li>\n<li>\nMicrosoft.WindowsDesktop.App (for building WinForms and WPF applications) Microsoft.WindowsDesktop.App<br \/>\n\uff08\u7528\u4e8e\u6784\u5efa WinForms \u548c WPF \u5e94\u7528\u7a0b\u5e8f\uff09\n<\/li>\n<\/ul>\n<p>If you are running a Windows OS, each of these must be version 6.0.0 (or higher). If you are not on Windows, you will just need the first two, Microsoft.NETCore.App and Microsoft.AspNetCore.App, and also be showing version 6.0.0 (or higher).<br \/>\n\u5982\u679c\u60a8\u8fd0\u884c\u7684\u662f Windows \u64cd\u4f5c\u7cfb\u7edf\uff0c\u5219\u5176\u4e2d\u6bcf\u4e2a\u90fd\u5fc5\u987b\u662f\u7248\u672c 6.0.0\uff08\u6216\u66f4\u9ad8\u7248\u672c\uff09\u3002\u5982\u679c\u60a8\u4e0d\u5728Windows\u4e0a\uff0c\u5219\u53ea\u9700\u8981\u524d\u4e24\u4e2a\uff0cMicrosoft.NETCore.App \u548c Microsoft.AspNetCore.App\uff0c\u5e76\u4e14\u8fd8\u663e\u793a\u7248\u672c6.0.0\uff08\u6216\u66f4\u9ad8\u7248\u672c\uff09\u3002<\/p>\n<p>Finally, to show all of the SDKs installed, enter the following:<br \/>\n\u6700\u540e\uff0c\u8981\u663e\u793a\u5df2\u5b89\u88c5\u7684\u6240\u6709 SDK\uff0c\u8bf7\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<p><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndotnet --list-sdks\n<\/pre>\n<\/p>\n<p>Again, the version must be 6.0.100 (or higher).<br \/>\n\u540c\u6837\uff0c\u7248\u672c\u5fc5\u987b\u4e3a 6.0.100\uff08\u6216\u66f4\u9ad8\u7248\u672c\uff09\u3002<\/p>\n<h2>Checking For Updates<\/h2>\n<p>\u68c0\u67e5\u66f4\u65b0<\/p>\n<p>New with .NET 6, the CLI has a new command that checks your installed versions of the .NET\/.NET Core SDKs and runtimes for updates. This command is backwards compatible, so it also checks for updates for .NET Core 3.1. It will also inform you if any of the installed SDK or runtimes are out of support (like the 2.x versions). To check the versions, enter the following command:<br \/>\n\u4f5c\u4e3a .NET 6 \u7684\u65b0\u589e\u529f\u80fd\uff0cCLI \u6709\u4e00\u4e2a\u65b0\u547d\u4ee4\uff0c\u7528\u4e8e\u68c0\u67e5\u5df2\u5b89\u88c5\u7684 .NET\/.NET Core SDK \u7248\u672c\u548c\u8fd0\u884c\u65f6\u662f\u5426\u6709\u66f4\u65b0\u3002\u6b64\u547d\u4ee4\u5411\u540e\u517c\u5bb9\uff0c\u56e0\u6b64\u5b83\u8fd8\u4f1a\u68c0\u67e5.NET Core 3.1.\u5982\u679c\u4efb\u4f55\u5df2\u5b89\u88c5\u7684 SDK \u6216\u8fd0\u884c\u65f6\u4e0d\u53d7\u652f\u6301\uff08\u5982 2.x \u7248\u672c\uff09\uff0c\u5b83\u8fd8\u4f1a\u901a\u77e5\u60a8\u3002\u8981\u68c0\u67e5\u7248\u672c\uff0c\u8bf7\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<p><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndotnet sdk check\n<\/pre>\n<\/p>\n<p>The command will not update any of the versions for you, it just reports the status. To update, follow the same procedure outlined above to download and install the new version(s).<br \/>\n\u8be5\u547d\u4ee4\u4e0d\u4f1a\u4e3a\u60a8\u66f4\u65b0\u4efb\u4f55\u7248\u672c\uff0c\u5b83\u53ea\u4f1a\u62a5\u544a\u72b6\u6001\u3002\u8981\u8fdb\u884c\u66f4\u65b0\uff0c\u8bf7\u6309\u7167\u4e0a\u8ff0\u76f8\u540c\u8fc7\u7a0b\u4e0b\u8f7d\u5e76\u5b89\u88c5\u65b0\u7248\u672c\u3002<\/p>\n<h2>Use an Earlier Version of the .NET (Core) SDK<\/h2>\n<p>\u4f7f\u7528\u65e9\u671f\u7248\u672c\u7684 .NET\uff08\u6838\u5fc3\uff09SDK<\/p>\n<p>Sometimes you might want to ensure you are using an older version of the .NET SDK. As an example, you are building your production applications using .NET 6. An early release candidate for .NET 7 is available, and you want to start experimenting with it while not putting your production work at risk. While Microsoft states that you can build previous versions of .NET applications with a later SDK, many developers and organizations aren\u2019t comfortable with release candidates, much less early beta\/preview releases.<br \/>\n\u6709\u65f6\uff0c\u4f60\u53ef\u80fd\u5e0c\u671b\u786e\u4fdd\u4f7f\u7528\u7684\u662f\u65e7\u7248\u672c\u7684 .NET SDK\u3002\u4f8b\u5982\uff0c\u60a8\u6b63\u5728\u4f7f\u7528 .NET 6 \u751f\u6210\u751f\u4ea7\u5e94\u7528\u7a0b\u5e8f\u3002.NET 7 \u7684\u65e9\u671f\u5019\u9009\u7248\u672c\u53ef\u7528\uff0c\u5e76\u4e14\u4f60\u5e0c\u671b\u5f00\u59cb\u8bd5\u9a8c\u5b83\uff0c\u540c\u65f6\u53c8\u4e0d\u4f7f\u751f\u4ea7\u5de5\u4f5c\u9762\u4e34\u98ce\u9669\u3002\u867d\u7136Microsoft\u58f0\u660e\u53ef\u4ee5\u4f7f\u7528\u66f4\u9ad8\u7248\u672c\u7684 SDK \u751f\u6210\u4ee5\u524d\u7248\u672c\u7684 .NET \u5e94\u7528\u7a0b\u5e8f\uff0c\u4f46\u8bb8\u591a\u5f00\u53d1\u4eba\u5458\u548c\u7ec4\u7ec7\u5bf9\u5019\u9009\u7248\u672c\u611f\u5230\u4e0d\u8212\u670d\uff0c\u66f4\u4e0d\u7528\u8bf4\u65e9\u671f\u6d4b\u8bd5\u7248\/\u9884\u89c8\u7248\u4e86\u3002<\/p>\n<p>If you need to pin your project to an earlier version of the .NET SDK, you can do that with a global. json file. To create this file, you can use this command, which pins the current folder and all subfolders to SDK version 5.0.400:<br \/>\n\u5982\u679c\u9700\u8981\u5c06\u9879\u76ee\u56fa\u5b9a\u5230\u65e9\u671f\u7248\u672c\u7684 .NET SDK\uff0c\u53ef\u4ee5\u4f7f\u7528\u5168\u5c40 JSON \u6587\u4ef6\u6267\u884c\u6b64\u64cd\u4f5c\u3002\u82e5\u8981\u521b\u5efa\u6b64\u6587\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff0c\u8be5\u547d\u4ee4\u5c06\u5f53\u524d\u6587\u4ef6\u5939\u548c\u6240\u6709\u5b50\u6587\u4ef6\u5939\u56fa\u5b9a\u5230 SDK \u7248\u672c 5.0.400\uff1a<\/p>\n<p><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndotnet new globaljson \u2013sdk-version 5.0.400\n<\/pre>\n<\/p>\n<p>This creates a global.json file that looks like this:<br \/>\n\u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a\u5982\u4e0b\u6240\u793a\u7684 global.json \u6587\u4ef6\uff1a<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\n{\n    &quot;sdk&quot;: {\n        &quot;version&quot;: &quot;5.0.400&quot;\n    }\n}\n<\/pre>\n<\/p>\n<p>Running dotnet.exe --version in this directory (or any subdirectory) will return 5.0.400.<br \/>\n\u5728\u6b64\u76ee\u5f55\uff08\u6216\u4efb\u4f55\u5b50\u76ee\u5f55\uff09\u4e2d\u8fd0\u884c dotnet.exe --version \u5c06\u8fd4\u56de 5.0.400\u3002<\/p>\n<h2>Building .NET Core Applications with Visual Studio<\/h2>\n<p>\u4f7f\u7528 Visual Studio \u6784\u5efa .NET Core \u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>If you have experience building applications using prior versions of Microsoft technologies, you are probably familiar with Visual Studio. The edition names and features sets have changed throughout the life of the product but have settled down since the release of .NET Core. Visual Studio is available in the following editions (for both Window and Mac):<br \/>\n\u5982\u679c\u60a8\u5177\u6709\u4f7f\u7528\u4ee5\u524d\u7248\u672c\u7684Microsoft\u6280\u672f\u6784\u5efa\u5e94\u7528\u7a0b\u5e8f\u7684\u7ecf\u9a8c\uff0c\u5219\u53ef\u80fd\u719f\u6089 Visual Studio\u3002\u7248\u672c\u540d\u79f0\u548c\u529f\u80fd\u96c6\u5728\u4ea7\u54c1\u7684\u6574\u4e2a\u751f\u547d\u5468\u671f\u4e2d\u53d1\u751f\u4e86\u53d8\u5316\uff0c\u4f46\u81ea .NET Core \u53d1\u5e03\u4ee5\u6765\u5df2\u7a33\u5b9a\u4e0b\u6765\u3002Visual Studio \u5728\u4ee5\u4e0b\u7248\u672c\u4e2d\u53ef\u7528\uff08\u9002\u7528\u4e8e Window \u548c Mac\uff09\uff1a<\/p>\n<ul>\n<li>\nVisual Studio 2022 Community (free)<br \/>\nVisual Studio 2022 \u793e\u533a\uff08\u514d\u8d39\uff09\n<\/li>\n<li>\nVisual Studio 2022 Professional (paid)<br \/>\n\u89c6\u89c9\u5de5\u4f5c\u5ba4 2022 \u4e13\u4e1a\u7248\uff08\u4ed8\u8d39\uff09\n<\/li>\n<li>\nVisual Studio 2022 Enterprise (paid)<br \/>\nVisual Studio 2022 \u4f01\u4e1a\u7248\uff08\u4ed8\u8d39\uff09\n<\/li>\n<\/ul>\n<p>The Community and Professional editions are essentially the same. The most significant difference is in the licensing model. Community is licensed for open source, academic, and small-business uses. Professional and Enterprise are commercial products that are licensed for any development, including enterprise development. As one would expect, the Enterprise edition has many additional features compared to the Professional edition.<br \/>\n\u793e\u533a\u7248\u548c\u4e13\u4e1a\u7248\u57fa\u672c\u76f8\u540c\u3002\u6700\u663e\u7740\u7684\u533a\u522b\u5728\u4e8e\u8bb8\u53ef\u6a21\u5f0f\u3002\u793e\u533a\u88ab\u8bb8\u53ef\u7528\u4e8e\u5f00\u6e90\u3001\u5b66\u672f\u548c\u5c0f\u578b\u4f01\u4e1a\u7528\u9014\u3002\u4e13\u4e1a\u7248\u548c\u4f01\u4e1a\u7248\u662f\u83b7\u5f97\u4efb\u4f55\u5f00\u53d1\u8bb8\u53ef\u7684\u5546\u4e1a\u4ea7\u54c1\uff0c\u5305\u62ec\u4f01\u4e1a\u5f00\u53d1\u3002\u6b63\u5982\u4eba\u4eec\u6240\u671f\u671b\u7684\u90a3\u6837\uff0c\u4e0e\u4e13\u4e1a\u7248\u76f8\u6bd4\uff0c\u4f01\u4e1a\u7248\u5177\u6709\u8bb8\u591a\u9644\u52a0\u529f\u80fd\u3002<\/p>\n<blockquote><p>\n\u25a0 Note  For specific licensing details, please go to www.visualstudio.com. licensing Microsoft products can be complex, and this book does not cover the details. For the purposes of writing (and following along with) this book, Community is legal to use.<br \/>\n\u6709\u5173\u5177\u4f53\u7684\u8bb8\u53ef\u8be6\u60c5\uff0c\u8bf7\u8f6c\u5230 www.visualstudio.com\u3002 \u8bb8\u53efMicrosoft\u4ea7\u54c1\u53ef\u80fd\u5f88\u590d\u6742\uff0c\u672c\u4e66\u4e0d\u6d89\u53ca\u8be6\u7ec6\u4fe1\u606f\u3002\u51fa\u4e8e\u64b0\u5199\uff08\u5e76\u9075\u5faa\uff09\u672c\u4e66\u7684\u76ee\u7684\uff0c\u793e\u533a\u662f\u5408\u6cd5\u4f7f\u7528\u7684\u3002\n<\/p><\/blockquote>\n<p>All Visual Studio editions ship with sophisticated code editors, integrated debuggers, GUI designers for desktop applications, and much more. Since they all share a common core set of features, the good news is that it is easy to move between them and feel quite comfortable with their basic operation.<br \/>\n\u6240\u6709Visual Studio\u7248\u672c\u90fd\u9644\u5e26\u590d\u6742\u7684\u4ee3\u7801\u7f16\u8f91\u5668\uff0c\u96c6\u6210\u8c03\u8bd5\u5668\uff0c\u7528\u4e8e\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u7684GUI\u8bbe\u8ba1\u5668\u7b49\u7b49\u3002\u7531\u4e8e\u5b83\u4eec\u90fd\u5177\u6709\u4e00\u7ec4\u5171\u540c\u7684\u6838\u5fc3\u529f\u80fd\uff0c\u56e0\u6b64\u597d\u6d88\u606f\u662f\u5f88\u5bb9\u6613\u5728\u5b83\u4eec\u4e4b\u95f4\u79fb\u52a8\u5e76\u4e14\u5bf9\u5b83\u4eec\u7684\u57fa\u672c\u64cd\u4f5c\u611f\u5230\u975e\u5e38\u8212\u670d\u3002<\/p>\n<h2>Installing Visual Studio 2022 (Windows)<\/h2>\n<p>\u5b89\u88c5 Visual Studio 2022 \uff08Windows\uff09<\/p>\n<p>Before using Visual Studio 2022 to develop, execute, and debug C# applications, you need to get it installed. The installation experience changed dramatically with the 2017 version and is worth discussing in more detail. If you have been using 2019, you will find the experience very similar.<\/p>\n<p>\u5728\u4f7f\u7528 Visual Studio 2022 \u5f00\u53d1\u3001\u6267\u884c\u548c\u8c03\u8bd5 C# \u5e94\u7528\u7a0b\u5e8f\u4e4b\u524d\uff0c\u9700\u8981\u5b89\u88c5\u5b83\u30022017 \u7248\u672c\u7684\u5b89\u88c5\u4f53\u9a8c\u53d1\u751f\u4e86\u5de8\u5927\u53d8\u5316\uff0c\u503c\u5f97\u66f4\u8be6\u7ec6\u5730\u8ba8\u8bba\u3002\u5982\u679c\u60a8\u4e00\u76f4\u5728\u4f7f\u75282019\uff0c\u60a8\u4f1a\u53d1\u73b0\u4f53\u9a8c\u975e\u5e38\u76f8\u4f3c\u3002<\/p>\n<blockquote><p>\n\u25a0 Note   You can download Visual Studio 2022 Community from www.visualstudio.com\/downloads.<br \/>\n\u60a8\u53ef\u4ee5\u4ece www.visualstudio.com\/downloads \u4e0b\u8f7d Visual Studio 2022 \u793e\u533a\u3002\n<\/p><\/blockquote>\n<p>The Visual Studio 2022 installation process is now broken down into application-type workloads. This allows you to install just the components you need for the type of applications you plan on building. For example, if you are going to build web applications, you would install the \u201cASP.NET and web development\u201d workload.<br \/>\nVisual Studio 2022 \u5b89\u88c5\u8fc7\u7a0b\u73b0\u5728\u5206\u89e3\u4e3a\u5e94\u7528\u7a0b\u5e8f\u7c7b\u578b\u7684\u5de5\u4f5c\u8d1f\u8f7d\u3002\u8fd9\u5141\u8bb8\u60a8\u4ec5\u5b89\u88c5\u8ba1\u5212\u6784\u5efa\u7684\u5e94\u7528\u7a0b\u5e8f\u7c7b\u578b\u6240\u9700\u7684\u7ec4\u4ef6\u3002\u4f8b\u5982\uff0c\u5982\u679c\u8981\u6784\u5efa Web \u5e94\u7528\u7a0b\u5e8f\uff0c\u5219\u9700\u8981\u5b89\u88c5\u201cASP.NET \u548c Web \u5f00\u53d1\u201d\u5de5\u4f5c\u8d1f\u8f7d\u3002<\/p>\n<p>Another (extremely) significant change is that Visual Studio 2022 supports true side-by-side installation.Note that I am not referring to just previous versions of Visual Studio but to Visual Studio 2022 itself! For example, on my main work computer, I have Visual Studio 2022 Enterprise installed for my professional work and Visual Studio 2022 Community for use in my books, courses, and conference lectures. If you have Professional or Enterprise supplied by your employer, you can still install the Community edition to work on open source projects (or the code in this book).<br \/>\n\u53e6\u4e00\u4e2a\uff08\u975e\u5e38\uff09\u91cd\u5927\u7684\u53d8\u5316\u662f Visual Studio 2022 \u652f\u6301\u771f\u6b63\u7684\u5e76\u884c\u5b89\u88c5\u3002\u8bf7\u6ce8\u610f\uff0c\u6211\u6307\u7684\u4e0d\u4ec5\u4ec5\u662f\u4ee5\u524d\u7248\u672c\u7684 Visual Studio \uff0c\u800c\u662f Visual Studio 2022 \u672c\u8eab\uff01\u4f8b\u5982\uff0c\u5728\u6211\u7684\u4e3b\u5de5\u4f5c\u8ba1\u7b97\u673a\u4e0a\uff0c\u6211\u4e3a\u6211\u7684\u4e13\u4e1a\u5de5\u4f5c\u5b89\u88c5\u4e86 Visual Studio 2022 \u4f01\u4e1a\u7248\uff0c\u5e76\u4e3a\u6211\u7684\u4e66\u7c4d\u3001\u8bfe\u7a0b\u548c\u4f1a\u8bae\u8bb2\u5ea7\u5b89\u88c5\u4e86 Visual Studio 2022 \u793e\u533a\u3002\u5982\u679c\u4f60\u7684\u96c7\u4e3b\u63d0\u4f9b\u4e86\u4e13\u4e1a\u7248\u6216\u4f01\u4e1a\u7248\uff0c\u4f60\u4ecd\u7136\u53ef\u4ee5\u5b89\u88c5\u793e\u533a\u7248\u6765\u5904\u7406\u5f00\u6e90\u9879\u76ee\uff08\u6216\u672c\u4e66\u4e2d\u7684\u4ee3\u7801\uff09\u3002<\/p>\n<p>When you launch the installer for Visual Studio 2022 Community, you are presented with the screen shown in Figure 2-1. This screen has all of the workloads available, the option to select individual components, and a summary on the right side showing what has been selected.<br \/>\n\u542f\u52a8 Visual Studio 2022 \u793e\u533a\u7684\u5b89\u88c5\u7a0b\u5e8f\u65f6\uff0c\u5c06\u663e\u793a\u5982\u56fe 2-1 \u6240\u793a\u7684\u5c4f\u5e55\u3002\u6b64\u5c4f\u5e55\u5305\u542b\u6240\u6709\u53ef\u7528\u7684\u5de5\u4f5c\u8d1f\u8f7d\u3001\u9009\u62e9\u5355\u4e2a\u7ec4\u4ef6\u7684\u9009\u9879\uff0c\u4ee5\u53ca\u53f3\u4fa7\u663e\u793a\u5df2\u9009\u62e9\u5185\u5bb9\u7684\u6458\u8981\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/miie.net\/img\/pro-csharp10\/images\/0201.png\" alt=\"Alt text\" \/><\/p>\n<p>Figure 2-1. The new Visual Studio installer<br \/>\n\u56fe 2-1\u3002 \u65b0\u7684 Visual Studio \u5b89\u88c5\u7a0b\u5e8f<\/p>\n<p>For this book, you will want to install the following workloads:<br \/>\n\u5bf9\u4e8e\u672c\u4e66\uff0c\u60a8\u9700\u8981\u5b89\u88c5\u4ee5\u4e0b\u5de5\u4f5c\u8d1f\u8f7d\uff1a<\/p>\n<ul>\n<li>\n.NET desktop development.NET<br \/>\n\u684c\u9762\u5f00\u53d1\n<\/li>\n<li>\nASP.NET and web development<br \/>\nASP.NET \u548c\u7f51\u7edc\u5f00\u53d1\n<\/li>\n<li>\nData storage and processing<br \/>\n\u6570\u636e\u5b58\u50a8\u548c\u5904\u7406\n<\/li>\n<\/ul>\n<p>On the \u201cIndividual components\u201d tab, also select Class Designer and Git for Windows (all under \u201cCode tools\u201d). Once you have all of them selected, click Install. This will provide you with everything you need to work through the examples in this book.<br \/>\n\u5728\u201c\u5355\u4e2a\u7ec4\u4ef6\u201d\u9009\u9879\u5361\u4e0a\uff0c\u8fd8\u9009\u62e9\u201c\u7c7b\u8bbe\u8ba1\u5668\u201d\u548c\u201c\u9002\u7528\u4e8e Windows\u7684 Git\u201d\uff08\u5168\u90e8\u5728\u201c\u4ee3\u7801\u5de5\u5177\u201d\u4e0b\uff09\u3002\u9009\u62e9\u6240\u6709\u8fd9\u4e9b\u9009\u9879\u540e\uff0c\u5355\u51fb\u201c\u5b89\u88c5\u201d\u3002\u8fd9\u5c06\u4e3a\u60a8\u63d0\u4f9b\u5b8c\u6210\u672c\u4e66\u4e2d\u793a\u4f8b\u6240\u9700\u7684\u4e00\u5207\u3002<\/p>\n<h2>Taking Visual Studio 2022 for a Test-Drive<\/h2>\n<p>\u5c06 Visual Studio 2022 \u4f5c\u4e3a\u8bd5\u9a7e<\/p>\n<p>Visual Studio 2022 is a complete IDE for software development using .NET and C#. Let\u2019s take a quick look at Visual Studio by building a simple .NET 6 Console application.<br \/>\nVisual Studio 2022 \u662f\u4e00\u4e2a\u5b8c\u6574\u7684 IDE\uff0c\u7528\u4e8e\u4f7f\u7528 .NET \u548c C# \u8fdb\u884c\u8f6f\u4ef6\u5f00\u53d1\u3002\u8ba9\u6211\u4eec\u901a\u8fc7\u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u7684 .NET 6 \u63a7\u5236\u53f0\u5e94\u7528\u7a0b\u5e8f\u6765\u5feb\u901f\u4e86\u89e3 Visual Studio\u3002<\/p>\n<h2>Using the New Project Dialog and C# Code Editor<\/h2>\n<p>\u4f7f\u7528\u201c\u65b0\u5efa\u9879\u76ee\u201d\u5bf9\u8bdd\u6846\u548c C# \u4ee3\u7801\u7f16\u8f91\u5668<\/p>\n<p>When you start Visual Studio, you will see the updated Launch dialog, as shown in Figure 2-2. The left side of the dialog has the most recently used solutions, and the right side has options for launching VisualStudio by launching code from a repository, opening an existing project\/solution, opening a local folder, or creating a new project. There is also an option to continue without any code, which just launches the Visual Studio IDE.<br \/>\n\u542f\u52a8 Visual Studio \u65f6\uff0c\u60a8\u5c06\u770b\u5230\u66f4\u65b0\u7684\u201c\u542f\u52a8\u201d\u5bf9\u8bdd\u6846\uff0c\u5982\u56fe 2-2 \u6240\u793a\u3002\u5bf9\u8bdd\u6846\u7684\u5de6\u4fa7\u5305\u542b\u6700\u8fd1\u4f7f\u7528\u7684\u89e3\u51b3\u65b9\u6848\uff0c\u53f3\u4fa7\u5305\u542b\u7528\u4e8e\u542f\u52a8 Visual \u7684\u9009\u9879\u901a\u8fc7\u4ece\u5b58\u50a8\u5e93\u542f\u52a8\u4ee3\u7801\u3001\u6253\u5f00\u73b0\u6709\u9879\u76ee\/\u89e3\u51b3\u65b9\u6848\u3001\u6253\u5f00\u672c\u5730\u6587\u4ef6\u5939\u6216\u521b\u5efa\u65b0\u9879\u76ee\u6765\u8fdb\u884c\u5de5\u4f5c\u5ba4\u3002\u8fd8\u6709\u4e00\u4e2a\u9009\u9879\u53ef\u4ee5\u5728\u6ca1\u6709\u4efb\u4f55\u4ee3\u7801\u7684\u60c5\u51b5\u4e0b\u7ee7\u7eed\uff0c\u5b83\u53ea\u4f1a\u542f\u52a8Visual Studio IDE\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/miie.net\/img\/pro-csharp10\/images\/0202.png\" alt=\"Alt text\" \/><\/p>\n<p>Figure 2-2. The new Visual Studio launch dialog<br \/>\n\u56fe 2-2\u3002 \u65b0\u7684 Visual Studio \u542f\u52a8\u5bf9\u8bdd\u6846<\/p>\n<p>Select the \u201cCreate a new project\u201d option, and you will be prompted with the \u201cCreate a new project\u201d dialog. As shown in Figure 2-3, recently used templates (if any) are on the left, and all available templates are on the right, including a set of filters and a search box.<br \/>\n\u9009\u62e9\u201c\u521b\u5efa\u65b0\u9879\u76ee\u201d\u9009\u9879\uff0c\u7cfb\u7edf\u5c06\u63d0\u793a\u60a8\u201c\u521b\u5efa\u65b0\u9879\u76ee\u201d\u5bf9\u8bdd\u6846\u3002\u5982\u56fe 2-3 \u6240\u793a\uff0c\u6700\u8fd1\u4f7f\u7528\u7684\u6a21\u677f\uff08\u5982\u679c\u6709\uff09\u4f4d\u4e8e\u5de6\u4fa7\uff0c\u6240\u6709\u53ef\u7528\u6a21\u677f\u4f4d\u4e8e\u53f3\u4fa7\uff0c\u5305\u62ec\u4e00\u7ec4\u7b5b\u9009\u5668\u548c\u4e00\u4e2a\u641c\u7d22\u6846\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/miie.net\/img\/pro-csharp10\/images\/0203.png\" alt=\"Alt text\" \/><\/p>\n<p>Figure 2-3. The \u201cCreate a new project\u201d dialog<br \/>\n\u56fe 2-3\u3002 \u201c\u521b\u5efa\u65b0\u9879\u76ee\u201d\u5bf9\u8bdd\u6846<\/p>\n<p>To start, create a new Console App, making sure to select the C# version and not the Visual Basic version.<br \/>\n\u9996\u5148\uff0c\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u63a7\u5236\u53f0\u5e94\u7528\uff0c\u786e\u4fdd\u9009\u62e9 C# \u7248\u672c\u800c\u4e0d\u662f Visual Basic \u7248\u672c\u3002<\/p>\n<p>The next screen is the \u201cConfigure your new project\u201d dialog, as shown in Figure 2-4. Enter SimpleCSharpConsoleApp for the project name and select a location for the project. The wizard will also create a Visual Studio solution, by default named after the project name.<br \/>\n\u4e0b\u4e00\u4e2a\u5c4f\u5e55\u662f\u201c\u914d\u7f6e\u65b0\u9879\u76ee\u201d\u5bf9\u8bdd\u6846\uff0c\u5982\u56fe 2-4 \u6240\u793a\u3002\u8f93\u5165 SimpleCSharpConsoleApp \u4f5c\u4e3a\u9879\u76ee\u540d\u79f0\uff0c\u5e76\u9009\u62e9\u9879\u76ee\u7684\u4f4d\u7f6e\u3002\u8be5\u5411\u5bfc\u8fd8\u5c06\u521b\u5efa\u4e00\u4e2a Visual Studio \u89e3\u51b3\u65b9\u6848\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u4ee5\u9879\u76ee\u540d\u79f0\u547d\u540d\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/miie.net\/img\/pro-csharp10\/images\/0204.png\" alt=\"Alt text\" \/><\/p>\n<p>Figure 2-4. The \u201cConfigure your new project\u201d dialog<br \/>\n\u56fe 2-4\u3002 \u201c\u914d\u7f6e\u65b0\u9879\u76ee\u201d\u5bf9\u8bdd\u6846<\/p>\n<blockquote><p>\nNote Creating solutions and projects can also be accomplished using the .nET Core Command line Interface (ClI). This will be covered with Visual Studio Code.<br \/>\n\u6ce8\u610f \u8fd8\u53ef\u4ee5\u4f7f\u7528 .nET Core \u547d\u4ee4\u884c\u754c\u9762 \uff08ClI\uff09 \u521b\u5efa\u89e3\u51b3\u65b9\u6848\u548c\u9879\u76ee\u3002\u8fd9\u5c06\u5728Visual Studio Code\u4e2d\u4ecb\u7ecd\u3002\n<\/p><\/blockquote>\n<p>The next screen prompts for the version of .NET to use. Make sure \u201c.NET 6.0 (Long-term support)\u201d is selected, as shown in Figure 2-5.<br \/>\n\u4e0b\u4e00\u4e2a\u5c4f\u5e55\u63d0\u793a\u8981\u4f7f\u7528\u7684 .NET \u7248\u672c\u3002\u786e\u4fdd\u9009\u4e2d\u201c.NET 6.0\uff08\u957f\u671f\u652f\u6301\uff09\u201d\uff0c\u5982\u56fe 2-5 \u6240\u793a\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/miie.net\/img\/pro-csharp10\/images\/0205.png\" alt=\"Alt text\" \/><\/p>\n<p>Figure 2-5. Chosing the .NET Version<br \/>\n\u56fe 2-5\u3002 \u9009\u62e9 .NET \u7248\u672c<\/p>\n<p>Once the project has been created, you will see that the initial C# code file (named Program.cs) has been opened in the code editor. The initial template just has a comment (the line starting with \/\/) and a single line of code that writes \u201cHello, World!\u201d to the console: <\/p>\n<p>\u521b\u5efa\u9879\u76ee\u540e\uff0c\u60a8\u5c06\u770b\u5230\u521d\u59cb C# \u4ee3\u7801\u6587\u4ef6\uff08\u540d\u4e3a Program.cs\uff09\u5df2\u5728\u4ee3\u7801\u7f16\u8f91\u5668\u4e2d\u6253\u5f00\u3002\u521d\u59cb\u6a21\u677f\u53ea\u6709\u4e00\u4e2a\u6ce8\u91ca\uff08\u4ee5 \/\/ \u5f00\u5934\u7684\u884c\uff09\u548c\u4e00\u884c\u4ee3\u7801\uff0c\u5c06\u201cHello\uff0c World\uff01\u201d\u5199\u5165\u63a7\u5236\u53f0\u3002<\/p>\n<p><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\n\/\/ See https:\/\/aka.ms\/new-console-template for more information \n\/\/\u6709\u5173\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605 https:\/\/aka.ms\/new-console-template\n\nConsole.WriteLine(&quot;Hello, World!&quot;);\n\n<\/pre>\n<\/p>\n<p>Those two lines of code are referred to as top level statements and serve as the entry point into the application. The next chapter covers top level statements and application entry points in detail. For now, realize that this is where the execution starts for your app, and ends when all of the lines have executed.<br \/>\n\u8fd9\u4e24\u884c\u4ee3\u7801\u79f0\u4e3a\u9876\u7ea7\u8bed\u53e5\uff0c\u7528\u4f5c\u5e94\u7528\u7a0b\u5e8f\u7684\u5165\u53e3\u70b9\u3002\u4e0b\u4e00\u7ae0\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u9876\u7ea7\u8bed\u53e5\u548c\u5e94\u7528\u7a0b\u5e8f\u5165\u53e3\u70b9\u3002\u73b0\u5728\uff0c\u8bf7\u6ce8\u610f\uff0c\u8fd9\u662f\u5e94\u7528\u7684\u6267\u884c\u5f00\u59cb\u4f4d\u7f6e\uff0c\u5e76\u5728\u6240\u6709\u884c\u90fd\u6267\u884c\u5b8c\u6bd5\u540e\u7ed3\u675f\u3002<\/p>\n<p>Replace the comment and the single line of code with the following:<br \/>\n\u5c06\u6ce8\u91ca\u548c\u5355\u884c\u4ee3\u7801\u66ff\u6362\u4e3a\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<p><pre class=\"brush: csharp; title: ; notranslate\" title=\"\"> \n\/\/ Set up Console UI (CUI)\n\/\/ \u8bbe\u7f6e Console UI \uff08CUI\uff09\n\nConsole.Title = &quot;My Rocking App&quot;;\nConsole.ForegroundColor = ConsoleColor.Yellow;\nConsole.BackgroundColor = ConsoleColor.Blue;\nConsole.WriteLine(&quot;*************************************&quot;);\nConsole.WriteLine(&quot;***** Welcome to My Rocking App *****&quot;);\nConsole.WriteLine(&quot;*************************************&quot;);\nConsole.BackgroundColor = ConsoleColor.Black;\n\n\/\/ Wait for Enter key to be pressed.\n\/\/ \u7b49\u5f85\u6309\u56de\u8f66\u952e\u3002\nConsole.ReadLine();\n<\/pre>\n<\/p>\n<blockquote><p>\nNote  You will notice as you type, Visual Studio attempts to complete the words for you. This is called IntelliSense (code completion help) and is integrated into Visual Studio and Visual Studio Code.<br \/>\n\u60a8\u4f1a\u6ce8\u610f\u5230\uff0c\u5f53\u60a8\u952e\u5165\u65f6\uff0cVisual Studio \u4f1a\u5c1d\u8bd5\u4e3a\u60a8\u5b8c\u6210\u5355\u8bcd\u3002\u8fd9\u79f0\u4e3aIntelliSense\uff08\u4ee3\u7801\u5b8c\u6210\u5e2e\u52a9\uff09\uff0c\u5e76\u96c6\u6210\u5230Visual Studio\u548cVisual Studio Code\u4e2d\u3002\n<\/p><\/blockquote>\n<p>Here, you are using the Console class defined in the System namespace. The System namespace is included as part of the global implicit using statements, so it isn\u2019t explicitly needed. This program does not do anything too interesting; however, note the final call to Console.ReadLine(). This is in place simply to ensure the user must press a key to terminate the application. With Visual Studio 2022, this is unnecessary as the VS debugger will pause the program and prevent it from exiting. If you were to navigate to the compiled version and run it, the program would disappear almost instantly when debugging the program!<br \/>\n\u5728\u8fd9\u91cc\uff0c\u60a8\u5c06\u4f7f\u7528\u5728\u7cfb\u7edf\u547d\u540d\u7a7a\u95f4\u4e2d\u5b9a\u4e49\u7684\u63a7\u5236\u53f0\u7c7b\u3002System \u547d\u540d\u7a7a\u95f4\u4f5c\u4e3a\u5168\u5c40\u9690\u5f0f using \u8bed\u53e5\u7684\u4e00\u90e8\u5206\u5305\u542b\u5728\u5185\uff0c\u56e0\u6b64\u4e0d\u9700\u8981\u5b83\u3002\u8be5\u7a0b\u5e8f\u4e0d\u4f1a\u505a\u4efb\u4f55\u592a\u6709\u8da3\u7684\u4e8b\u60c5;\u4f46\u662f\uff0c\u8bf7\u6ce8\u610f\u5bf9 Console.ReadLine\uff08\uff09 \u7684\u6700\u540e\u4e00\u6b21\u8c03\u7528\u3002\u8fd9\u6837\u505a\u53ea\u662f\u4e3a\u4e86\u786e\u4fdd\u7528\u6237\u5fc5\u987b\u6309\u67d0\u4e2a\u952e\u624d\u80fd\u7ec8\u6b62\u5e94\u7528\u7a0b\u5e8f\u3002\u5728 Visual Studio 2022 \u4e2d\uff0c\u8fd9\u662f\u4e0d\u5fc5\u8981\u7684\uff0c\u56e0\u4e3a VS \u8c03\u8bd5\u5668\u5c06\u6682\u505c\u7a0b\u5e8f\u5e76\u963b\u6b62\u5176\u9000\u51fa\u3002\u5982\u679c\u8981\u5bfc\u822a\u5230\u7f16\u8bd1\u7248\u672c\u5e76\u8fd0\u884c\u5b83\uff0c\u5219\u5728\u8c03\u8bd5\u7a0b\u5e8f\u65f6\uff0c\u7a0b\u5e8f\u51e0\u4e4e\u4f1a\u7acb\u5373\u6d88\u5931\uff01<\/p>\n<blockquote><p>\n\u25a0 Note  If you want to change the VS debugging experience to automatically end the program, select Tools \u27a4Options \u27a4 Debugging \u27a4 automatically close the console when debugging stops.<br \/>\n\u5982\u679c\u8981\u66f4\u6539 VS \u8c03\u8bd5\u4f53\u9a8c\u4ee5\u81ea\u52a8\u7ed3\u675f\u7a0b\u5e8f\uff0c\u8bf7\u9009\u62e9\u201c\u5de5\u5177\u201d\u27a4\u9009\u9879 \u27a4 \u8c03\u8bd5 \u27a4 \u8c03\u8bd5\u505c\u6b62\u65f6\u81ea\u52a8\u5173\u95ed\u63a7\u5236\u53f0\u3002\n<\/p><\/blockquote>\n<h2>Changing the Target .NET Core Framework<\/h2>\n<p>\u66f4\u6539\u76ee\u6807 .NET Core \u6846\u67b6<\/p>\n<p>When creating this project, you selected the version of .NET that you wanted to use. If you chose the wrong one (or want to change it for some other reason), double-click the project name in Solution Explorer. This opens the project file in the editor (this feature was introduced with Visual Studio 2019 and .NET Core).You can also edit the project file by right-clicking the project name in Solution Explorer and selecting \u201cEdit Project file.\u201d You will see the following:<br \/>\n\u521b\u5efa\u6b64\u9879\u76ee\u65f6\uff0c\u9009\u62e9\u4e86\u8981\u4f7f\u7528\u7684 .NET \u7248\u672c\u3002\u5982\u679c\u9009\u62e9\u4e86\u9519\u8bef\u7684\u9879\u76ee\u540d\u79f0\uff08\u6216\u51fa\u4e8e\u5176\u4ed6\u539f\u56e0\u60f3\u8981\u66f4\u6539\u5b83\uff09\uff0c\u8bf7\u5728\u201c\u89e3\u51b3\u65b9\u6848\u8d44\u6e90\u7ba1\u7406\u5668\u201d\u4e2d\u53cc\u51fb\u9879\u76ee\u540d\u79f0\u3002\u8fd9\u5c06\u5728\u7f16\u8f91\u5668\u4e2d\u6253\u5f00\u9879\u76ee\u6587\u4ef6\uff08\u6b64\u529f\u80fd\u968f Visual Studio 2019 \u548c .NET Core \u4e00\u8d77\u5f15\u5165\uff09\u3002\u8fd8\u53ef\u4ee5\u901a\u8fc7\u5728\u201c\u89e3\u51b3\u65b9\u6848\u8d44\u6e90\u7ba1\u7406\u5668\u201d\u4e2d\u53f3\u952e\u5355\u51fb\u9879\u76ee\u540d\u79f0\u5e76\u9009\u62e9\u201c\u7f16\u8f91\u9879\u76ee\u6587\u4ef6\u201d\u6765\u7f16\u8f91\u9879\u76ee\u6587\u4ef6\u3002\u60a8\u5c06\u770b\u5230\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<p><pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;Project Sdk=&quot;Microsoft.NET.Sdk&quot;&gt;\n    &lt;PropertyGroup&gt;\n        &lt;OutputType&gt;Exe&lt;\/OutputType&gt;\n        &lt;TargetFramework&gt;net6.0&lt;\/TargetFramework&gt;\n        &lt;ImplicitUsings&gt;enable&lt;\/ImplicitUsings&gt;\n        &lt;Nullable&gt;enable&lt;\/Nullable&gt;\n    &lt;\/PropertyGroup&gt;\n&lt;\/Project&gt;\n<\/pre>\n<\/p>\n<p>To change the .NET version to version 5, for example, simply change the TargetFramework value to net5.0, as shown here:<br \/>\n\u4f8b\u5982\uff0c\u82e5\u8981\u5c06 .NET \u7248\u672c\u66f4\u6539\u4e3a\u7248\u672c 5\uff0c\u53ea\u9700\u5c06 TargetFramework \u503c\u66f4\u6539\u4e3a net5.0\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<p><pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;Project Sdk=&quot;Microsoft.NET.Sdk&quot;&gt;\n    &lt;PropertyGroup&gt;\n        &lt;OutputType&gt;Exe&lt;\/OutputType&gt;\n        &lt;TargetFramework&gt;net5.0&lt;\/TargetFramework&gt;\n        &lt;ImplicitUsings&gt;enable&lt;\/ImplicitUsings&gt;\n        &lt;Nullable&gt;enable&lt;\/Nullable&gt;\n        &lt;\/PropertyGroup&gt;\n    &lt;\/Project&gt;\n<\/pre>\n<\/p>\n<p>You can also change the target framework by right-clicking the project name in Solution Explorer and selecting Properties, opening the Application tab, and updating the Target Framework value, as shown in Figure 2-6.<br \/>\n\u8fd8\u53ef\u4ee5\u901a\u8fc7\u5728\u201c\u89e3\u51b3\u65b9\u6848\u8d44\u6e90\u7ba1\u7406\u5668\u201d\u4e2d\u53f3\u952e\u5355\u51fb\u9879\u76ee\u540d\u79f0\u5e76\u9009\u62e9\u201c\u5c5e\u6027\u201d\uff0c\u6253\u5f00\u201c\u5e94\u7528\u7a0b\u5e8f\u201d\u9009\u9879\u5361\u5e76\u66f4\u65b0\u201c\u76ee\u6807\u6846\u67b6\u201d\u503c\u6765\u66f4\u6539\u76ee\u6807\u6846\u67b6\uff0c\u5982\u56fe 2-6 \u6240\u793a\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/miie.net\/img\/pro-csharp10\/images\/0206.png\" alt=\"Alt text\" \/><\/p>\n<p>Figure 2-6. Changing the target framework for your application<br \/>\n\u56fe 2-6\u3002 \u66f4\u6539\u5e94\u7528\u7a0b\u5e8f\u7684\u76ee\u6807\u6846\u67b6<\/p>\n<h2>Using C# 10 Features<\/h2>\n<p>\u4f7f\u7528 C# 10 \u529f\u80fd<\/p>\n<p>In versions of .NET and the .NET Framework, the version of C# supported by a project could be changed. Since the release of .NET Core 3.0 (and each subsequent.NET version), the version of C# used is tied into the .NET Core\/.NET version. For .NET 6.0 projects, the language version is locked into C# 10. Table 2-2 lists the target frameworks (.NET, .NET Core, .NET Standard, and .NET Framework) and the default C# version utilized.<br \/>\n\u5728 .NET \u548c .NET Framework \u7248\u672c\u4e2d\uff0c\u53ef\u4ee5\u66f4\u6539\u9879\u76ee\u652f\u6301\u7684 C# \u7248\u672c\u3002\u81ea .NET Core 3.0\uff08\u4ee5\u53ca\u6bcf\u4e2a subsequent.NET \u7248\u672c\uff09\u53d1\u5e03\u4ee5\u6765\uff0c\u4f7f\u7528\u7684 C# \u7248\u672c\u4e0e .NET Core\/.NET \u7248\u672c\u76f8\u5173\u8054\u3002\u5bf9\u4e8e .NET 6.0 \u9879\u76ee\uff0c\u8bed\u8a00\u7248\u672c\u9501\u5b9a\u5728 C# 10 \u4e2d\u3002\u8868 2-2 \u5217\u51fa\u4e86\u76ee\u6807\u6846\u67b6\uff08.NET\u3001.NET Core\u3001.NET Standard \u548c .NET Framework\uff09\u548c\u6240\u4f7f\u7528\u7684\u9ed8\u8ba4 C# \u7248\u672c\u3002<\/p>\n<p>Table 2-2. C# 8 Version and Target Framework \u8868 2-2. C# 8 \u7248\u672c\u548c\u76ee\u6807\u6846\u67b6<\/p>\n<table>\n<thead>\n<tr>\n<th>Target Framework \u76ee\u6807\u6846\u67b6<\/th>\n<th>Version \u7248\u672c<\/th>\n<th>C# Language Version Default C#\u8bed\u8a00\u7248\u672c<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>.NET<\/td>\n<td>6.x<\/td>\n<td>C# 10.0<\/td>\n<\/tr>\n<tr>\n<td>.NET<\/td>\n<td>5.x<\/td>\n<td>C# 9.0<\/td>\n<\/tr>\n<tr>\n<td>.NET Core<\/td>\n<td>3.x<\/td>\n<td>C# 8.0<\/td>\n<\/tr>\n<tr>\n<td>.NET Core<\/td>\n<td>2.x<\/td>\n<td>C# 7.3<\/td>\n<\/tr>\n<tr>\n<td>.NET Standard<\/td>\n<td>2.1<\/td>\n<td>C# 8.0<\/td>\n<\/tr>\n<tr>\n<td>.NET Standard<\/td>\n<td>2.0<\/td>\n<td>C# 7.3<\/td>\n<\/tr>\n<tr>\n<td>.NET Standard<\/td>\n<td>1.x<\/td>\n<td>C# 7.3<\/td>\n<\/tr>\n<tr>\n<td>.NET Framework<\/td>\n<td>all<\/td>\n<td>C# 7.3<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Running and Debugging Your Project<\/h2>\n<p>\u8fd0\u884c\u548c\u8c03\u8bd5\u9879\u76ee<\/p>\n<p>To run your program and see the output, press the Ctrl+F5 keyboard command (which is also accessed from the Debug \u27a4 Start Without Debugging menu option). Once you do, you will see a Windows console window pop on the screen with your custom (and colorful) message. Be aware that when you \u201crun\u201d your program with Ctrl+F5, you bypass the integrated debugger.<br \/>\n\u82e5\u8981\u8fd0\u884c\u7a0b\u5e8f\u5e76\u67e5\u770b\u8f93\u51fa\uff0c\u8bf7\u6309 Ctrl+F5 \u952e\u76d8\u547d\u4ee4\uff08\u4e5f\u53ef\u4ece\u201c\u8c03\u8bd5\u201d\u27a4\u201c\u542f\u52a8\uff08\u4e0d\u8c03\u8bd5\uff09\u83dc\u5355\u9009\u9879\u8bbf\u95ee\u8be5\u547d\u4ee4\uff09\u3002\u5b8c\u6210\u540e\uff0c\u60a8\u5c06\u770b\u5230\u5c4f\u5e55\u4e0a\u5f39\u51fa\u4e00\u4e2aWindows\u63a7\u5236\u53f0\u7a97\u53e3\uff0c\u5176\u4e2d\u5305\u542b\u81ea\u5b9a\u4e49\uff08\u548c\u5f69\u8272\uff09\u6d88\u606f\u3002\u8bf7\u6ce8\u610f\uff0c\u4f7f\u7528 Ctrl+F5 \u201c\u8fd0\u884c\u201d\u7a0b\u5e8f\u65f6\uff0c\u4f1a\u7ed5\u8fc7\u96c6\u6210\u8c03\u8bd5\u5668\u3002<\/p>\n<blockquote><p>\n\u25a0 Note  .NET applications can also be compiled and executed using the ClI. To run your project, enter dotnet run in the same directory as the project file (SimpleCSharpApp.csproj in this example). The dotnet run command also automatically builds the project.<br \/>\n.NET \u5e94\u7528\u7a0b\u5e8f\u4e5f\u53ef\u4ee5\u4f7f\u7528 ClI \u7f16\u8bd1\u548c\u6267\u884c\u3002\u82e5\u8981\u8fd0\u884c\u9879\u76ee\uff0c\u8bf7\u5728\u4e0e\u9879\u76ee\u6587\u4ef6\u76f8\u540c\u7684\u76ee\u5f55\u4e2d\u8f93\u5165 dotnet run\uff08\u5728\u6b64\u793a\u4f8b\u4e2d\u4e3a SimpleCSharpApp.csproj\uff09\u3002dotnet run \u547d\u4ee4\u4e5f\u4f1a\u81ea\u52a8\u751f\u6210\u9879\u76ee\u3002\n<\/p><\/blockquote>\n<p>If you need to debug your code (which will certainly be important when building larger programs), your first step is to set breakpoints at the code statement you want to examine. Although there is not much code in this example, set a breakpoint by clicking the leftmost gray bar of the code editor (note that breakpoints are marked with a red dot icon; see Figure 2-7).<br \/>\n\u5982\u679c\u9700\u8981\u8c03\u8bd5\u4ee3\u7801\uff08\u8fd9\u5728\u6784\u5efa\u5927\u578b\u7a0b\u5e8f\u65f6\u80af\u5b9a\u5f88\u91cd\u8981\uff09\uff0c\u7b2c\u4e00\u6b65\u662f\u5728\u8981\u68c0\u67e5\u7684\u4ee3\u7801\u8bed\u53e5\u5904\u8bbe\u7f6e\u65ad\u70b9\u3002\u5c3d\u7ba1\u6b64\u793a\u4f8b\u4e2d\u7684\u4ee3\u7801\u4e0d\u591a\uff0c\u4f46\u8bf7\u901a\u8fc7\u5355\u51fb\u4ee3\u7801\u7f16\u8f91\u5668\u6700\u5de6\u4fa7\u7684\u7070\u8272\u6761\u6765\u8bbe\u7f6e\u65ad\u70b9\uff08\u8bf7\u6ce8\u610f\uff0c\u65ad\u70b9\u7528\u7ea2\u70b9\u56fe\u6807\u6807\u8bb0;\u8bf7\u53c2\u9605\u56fe 2-7\uff09\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/miie.net\/img\/pro-csharp10\/images\/0207.png\" alt=\"Alt text\" \/><\/p>\n<p>Figure 2-7. Setting breakpoints<br \/>\n\u56fe 2-7\u3002 \u8bbe\u7f6e\u65ad\u70b9<\/p>\n<p>If you now press the F5 key (or use the Debug \u27a4 Start Debugging menu option or click the green arrow with Start next to it in the toolbar), your program will halt at each breakpoint. As you would expect, you can interact with the debugger using the various toolbar buttons and menu options of the IDE. Once you have evaluated all breakpoints, the application will eventually terminate once the statements have completed.<br \/>\n\u5982\u679c\u73b0\u5728\u6309 F5 \u952e\uff08\u6216\u4f7f\u7528\u201c\u8c03\u8bd5\u201d\u27a4\u201c\u542f\u52a8\u8c03\u8bd5\u201d\u83dc\u5355\u9009\u9879\uff0c\u6216\u5355\u51fb\u5de5\u5177\u680f\u4e2d\u65c1\u8fb9\u5e26\u6709\u201c\u5f00\u59cb\u201d\u7684\u7eff\u8272\u7bad\u5934\uff09\uff0c\u5219\u7a0b\u5e8f\u5c06\u5728\u6bcf\u4e2a\u65ad\u70b9\u5904\u505c\u6b62\u3002\u5982\u60a8\u6240\u6599\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 IDE \u7684\u5404\u79cd\u5de5\u5177\u680f\u6309\u94ae\u548c\u83dc\u5355\u9009\u9879\u4e0e\u8c03\u8bd5\u5668\u8fdb\u884c\u4ea4\u4e92\u3002\u8bc4\u4f30\u6240\u6709\u65ad\u70b9\u540e\uff0c\u5e94\u7528\u7a0b\u5e8f\u6700\u7ec8\u5c06\u5728\u8bed\u53e5\u5b8c\u6210\u540e\u7ec8\u6b62\u3002<\/p>\n<blockquote><p>\n\u25a0 Note  Microsoft IDEs have sophisticated debuggers, and you will learn about various techniques over the chapters to come. For now, be aware that when you are in a debugging session, a large number of useful options will appear under the Debug menu. Take a moment to verify this for yourself.<br \/>\n\u8bf7\u6ce8\u610fMicrosoft IDE \u5177\u6709\u590d\u6742\u7684\u8c03\u8bd5\u5668\uff0c\u60a8\u5c06\u5728\u540e\u9762\u7684\u7ae0\u8282\u4e2d\u4e86\u89e3\u5404\u79cd\u6280\u672f\u3002\u73b0\u5728\uff0c\u8bf7\u6ce8\u610f\uff0c\u5f53\u60a8\u5904\u4e8e\u8c03\u8bd5\u4f1a\u8bdd\u4e2d\u65f6\uff0c\u201c\u8c03\u8bd5\u201d\u83dc\u5355\u4e0b\u5c06\u51fa\u73b0\u5927\u91cf\u6709\u7528\u7684\u9009\u9879\u3002\u82b1\u70b9\u65f6\u95f4\u81ea\u5df1\u9a8c\u8bc1\u4e00\u4e0b\u3002\n<\/p><\/blockquote>\n<h2>Using Solution Explorer<\/h2>\n<p>\u4f7f\u7528\u89e3\u51b3\u65b9\u6848\u8d44\u6e90\u7ba1\u7406\u5668<\/p>\n<p>If you look to the right of the text editor, you will see the Solution Explorer window, which shows you a few important things. First, notice that the new project wizard has created a solution along with the single project. This can be confusing at first, as they both have been given the same name<br \/>\n(SimpleCSharpConsoleApp). The idea here is that a \u201csolution\u201d can contain multiple projects that all work together. For example, your solution might include three class libraries, one WPF application, and one ASP. NET Core web service. The earlier chapters of this book will almost always have a single for the example code; however, when you build some more complex examples, you will see how to add new projects to your initial solution.<br \/>\n\u5982\u679c\u67e5\u770b\u6587\u672c\u7f16\u8f91\u5668\u7684\u53f3\u4fa7\uff0c\u5c06\u770b\u5230\u201c\u89e3\u51b3\u65b9\u6848\u8d44\u6e90\u7ba1\u7406\u5668\u201d\u7a97\u53e3\uff0c\u5176\u4e2d\u663e\u793a\u4e86\u4e00\u4e9b\u91cd\u8981\u5185\u5bb9\u3002\u9996\u5148\uff0c\u8bf7\u6ce8\u610f\uff0c\u65b0\u5efa\u9879\u76ee\u5411\u5bfc\u5df2\u4e0e\u5355\u4e2a\u9879\u76ee\u4e00\u8d77\u521b\u5efa\u4e86\u4e00\u4e2a\u89e3\u51b3\u65b9\u6848\u3002\u8d77\u521d\u8fd9\u53ef\u80fd\u4f1a\u4ee4\u4eba\u56f0\u60d1\uff0c\u56e0\u4e3a\u5b83\u4eec\u90fd\u88ab\u8d4b\u4e88\u4e86\u76f8\u540c\u7684\u540d\u79f0\uff08SimpleCSharpConsoleApp\uff09\u3002\u8fd9\u91cc\u7684\u60f3\u6cd5\u662f\uff0c\u4e00\u4e2a\u201c\u89e3\u51b3\u65b9\u6848\u201d\u53ef\u4ee5\u5305\u542b\u591a\u4e2a\u534f\u540c\u5de5\u4f5c\u7684\u9879\u76ee\u3002\u4f8b\u5982\uff0c\u60a8\u7684\u89e3\u51b3\u65b9\u6848\u53ef\u80fd\u5305\u62ec\u4e09\u4e2a\u7c7b\u5e93\u3001\u4e00\u4e2a WPF \u5e94\u7528\u7a0b\u5e8f\u548c\u4e00\u4e2a ASP. NET Core Web \u670d\u52a1\u3002\u672c\u4e66\u524d\u9762\u7684\u7ae0\u8282\u51e0\u4e4e\u603b\u662f\u6709\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801;\u4f46\u662f\uff0c\u5f53\u60a8\u751f\u6210\u4e00\u4e9b\u66f4\u590d\u6742\u7684\u793a\u4f8b\u65f6\uff0c\u60a8\u5c06\u770b\u5230\u5982\u4f55\u5c06\u65b0\u9879\u76ee\u6dfb\u52a0\u5230\u521d\u59cb\u89e3\u51b3\u65b9\u6848\u4e2d\u3002<\/p>\n<blockquote><p>\n\u25a0 Note  Be aware that when you select the solution in the Solution Explorer window, the IDE\u2019s menu system will show you a different set of choices than when you select a project. If you ever find yourself wondering where a certain menu item has disappeared to, double-check you did not accidentally select the wrong node.<br \/>\n\u8bf7\u6ce8\u610f\uff0c\u5728\u201c\u89e3\u51b3\u65b9\u6848\u8d44\u6e90\u7ba1\u7406\u5668\u201d\u7a97\u53e3\u4e2d\u9009\u62e9\u89e3\u51b3\u65b9\u6848\u65f6\uff0cIDE \u7684\u83dc\u5355\u7cfb\u7edf\u5c06\u663e\u793a\u4e00\u7ec4\u4e0e\u9009\u62e9\u9879\u76ee\u65f6\u4e0d\u540c\u7684\u9009\u9879\u96c6\u3002\u5982\u679c\u60a8\u53d1\u73b0\u81ea\u5df1\u60f3\u77e5\u9053\u67d0\u4e2a\u83dc\u5355\u9879\u6d88\u5931\u5230\u54ea\u91cc\uff0c\u8bf7\u4ed4\u7ec6\u68c0\u67e5\u60a8\u662f\u5426\u610f\u5916\u9009\u62e9\u4e86\u9519\u8bef\u7684\u8282\u70b9\u3002\n<\/p><\/blockquote>\n<h2>Using the Visual Class Diagram Tool<\/h2>\n<p>\u4f7f\u7528\u53ef\u89c6\u7c7b\u56fe\u5de5\u5177<\/p>\n<p>Visual Studio also gives you the ability to design classes and other types (such as interfaces or delegates) in a visual manner. The Class Diagram provides tools that allow you to create, view, and modify the objects in your project and their relationships with other objects. Using this tool, you are able to visually add (or remove) members to (or from) a type and have your modifications reflected in the corresponding C# file. Also, as you modify a given C# file, changes are reflected in the class diagram.<br \/>\nVisual Studio \u8fd8\u4f7f\u60a8\u80fd\u591f\u4ee5\u53ef\u89c6\u65b9\u5f0f\u8bbe\u8ba1\u7c7b\u548c\u5176\u4ed6\u7c7b\u578b\uff08\u5982\u63a5\u53e3\u6216\u59d4\u6258\uff09\u3002\u7c7b\u56fe\u63d0\u4f9b\u4e86\u4e00\u4e9b\u5de5\u5177\uff0c\u53ef\u7528\u4e8e\u521b\u5efa\u3001\u67e5\u770b\u548c\u4fee\u6539\u9879\u76ee\u4e2d\u7684\u5bf9\u8c61\u53ca\u5176\u4e0e\u5176\u4ed6\u5bf9\u8c61\u7684\u5173\u7cfb\u3002\u4f7f\u7528\u6b64\u5de5\u5177\uff0c\u53ef\u4ee5\u76f4\u89c2\u5730\u5411\u7c7b\u578b\u6dfb\u52a0\uff08\u6216\u5220\u9664\uff09\u6210\u5458\uff0c\u5e76\u5c06\u4fee\u6539\u53cd\u6620\u5728\u76f8\u5e94\u7684 C# \u6587\u4ef6\u4e2d\u3002\u6b64\u5916\uff0c\u4fee\u6539\u7ed9\u5b9a\u7684 C# \u6587\u4ef6\u65f6\uff0c\u66f4\u6539\u5c06\u53cd\u6620\u5728\u7c7b\u56fe\u4e2d\u3002<\/p>\n<blockquote><p>\n\u25a0 Note  This book only uses the Class Diagram tool occasionally to accentuate certain concepts. It is shown here for completeness, and the choice to use it or the text editor is entirely up to you. The overwhelming majority of the examples use the text editor of Visual Studio\/Visual Studio Code.<br \/>\n\u672c\u4e66\u53ea\u662f\u5076\u5c14\u4f7f\u7528\u7c7b\u56fe\u5de5\u5177\u6765\u5f3a\u8c03\u67d0\u4e9b\u6982\u5ff5\u3002\u6b64\u5904\u663e\u793a\u5b83\u662f\u4e3a\u4e86\u5b8c\u6574\u6027\uff0c\u4f7f\u7528\u5b83\u8fd8\u662f\u6587\u672c\u7f16\u8f91\u5668\u5b8c\u5168\u53d6\u51b3\u4e8e\u60a8\u3002\u7edd\u5927\u591a\u6570\u793a\u4f8b\u4f7f\u7528Visual Studio\/Visual Studio Code\u7684\u6587\u672c\u7f16\u8f91\u5668\u3002\n<\/p><\/blockquote>\n<p>To access the visual class designer tools, the first step is to insert a new class diagram file. To do so, select project in the Solution Explorer, then activate the Project \u27a4 Add New Item menu option and locate the Class Diagram type (Figure 2-8). \u82e5\u8981\u8bbf\u95ee\u53ef\u89c6\u5316\u7c7b\u8bbe\u8ba1\u5668\u5de5\u5177\uff0c\u7b2c\u4e00\u6b65\u662f\u63d2\u5165\u65b0\u7684\u7c7b\u56fe\u6587\u4ef6\u3002\u4e3a\u6b64\uff0c\u8bf7\u5728\u201c\u89e3\u51b3\u65b9\u6848\u8d44\u6e90\u7ba1\u7406\u5668\u201d\u4e2d\u9009\u62e9\u201c\u9879\u76ee\u201d\uff0c\u7136\u540e\u6fc0\u6d3b\u201c\u9879\u76ee\u201d\u27a4\u201c\u6dfb\u52a0\u65b0\u9879\u201d\u83dc\u5355\u9009\u9879\u5e76\u627e\u5230\u201c\u7c7b\u56fe\u201d\u7c7b\u578b\uff08\u56fe 2-8\uff09\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/miie.net\/img\/pro-csharp10\/images\/0208.png\" alt=\"Alt text\" \/><\/p>\n<p>Figure 2-8. Inserting a class diagram file into the current project<br \/>\n\u56fe 2-8\u3002 \u5c06\u7c7b\u5173\u7cfb\u56fe\u6587\u4ef6\u63d2\u5165\u5230\u5f53\u524d\u9879\u76ee\u4e2d<\/p>\n<p>Initially, the designer will be empty; however, you can drag and drop files from your Solution Explorer window on the surface or right click on the design surface to create new classes. To get started, create a new class in your project by right clicking on the project and selecting Add \u27a4 Class. In the Add New Item \u2013 SimpleCSharpConsoleApp dialog, select Class, and name it Car.cs, as shown in Figure 2-9.<br \/>\n\u6700\u521d\uff0c\u8bbe\u8ba1\u5668\u5c06\u662f\u7a7a\u7684;\u4f46\u662f\uff0c\u53ef\u4ee5\u5c06\u6587\u4ef6\u4ece\u201c\u89e3\u51b3\u65b9\u6848\u8d44\u6e90\u7ba1\u7406\u5668\u201d\u7a97\u53e3\u62d6\u653e\u5230\u56fe\u9762\u4e0a\uff0c\u6216\u53f3\u952e\u5355\u51fb\u8bbe\u8ba1\u56fe\u9762\u4ee5\u521b\u5efa\u65b0\u7c7b\u3002\u8981\u5f00\u59cb\u4f7f\u7528\uff0c\u8bf7\u5728\u9879\u76ee\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u7c7b\uff0c\u65b9\u6cd5\u662f\u53f3\u952e\u5355\u51fb\u8be5\u9879\u76ee\u5e76\u9009\u62e9\u6dfb\u52a0 \u27a4 \u7c7b\u3002\u5728\u201c\u6dfb\u52a0\u65b0\u9879 \u2013 SimpleCSharpConsoleApp\u201d\u5bf9\u8bdd\u6846\u4e2d\uff0c\u9009\u62e9\u201c\u7c7b\u201d\uff0c\u5e76\u5c06\u5176\u547d\u540d\u4e3a Car.cs\uff0c\u5982\u56fe 2-9 \u6240\u793a\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/miie.net\/img\/pro-csharp10\/images\/0209.png\" alt=\"Alt text\" \/><\/p>\n<p>Figure 2-9. The Add New Item Dialog<br \/>\n\u56fe 2-9\u3002 \u201c\u6dfb\u52a0\u65b0\u9879\u201d\u5bf9\u8bdd\u6846<\/p>\n<p>Update the code to the following to create a Car class (you will learn all about classes over the next few chapters):<br \/>\n\u5c06\u4ee3\u7801\u66f4\u65b0\u4e3a\u4ee5\u4e0b\u5185\u5bb9\u4ee5\u521b\u5efa Car \u7c7b\uff08\u60a8\u5c06\u5728\u63a5\u4e0b\u6765\u7684\u51e0\u7ae0\u4e2d\u4e86\u89e3\u6709\u5173\u7c7b\u7684\u6240\u6709\u4fe1\u606f\uff09\uff1a<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nnamespace SimpleCSharpConsoleApp;\npublic class Car\n{\n    public string PetName { get; set; }\n    public string Make { get; set; }\n}\n<\/pre>\n<\/p>\n<p>After saving the file, drag the Car.cs file from the Solution Explorer onto the Class Diagram. Once you do this, you will find a visual representation of the class. If you click the arrow icon for a given type, you can show or hide the type\u2019s members. Underneath the Class Diagram is the Class Details window, which shows the specifics of the selected class diagram (see Figure 2-10).<br \/>\n\u4fdd\u5b58\u6587\u4ef6\u540e\uff0c\u5c06 Car.cs \u6587\u4ef6\u4ece\u89e3\u51b3\u65b9\u6848\u8d44\u6e90\u7ba1\u7406\u5668\u62d6\u5230\u7c7b\u56fe\u4e0a\u3002\u5b8c\u6210\u6b64\u64cd\u4f5c\u540e\uff0c\u60a8\u5c06\u627e\u5230\u7c7b\u7684\u53ef\u89c6\u5316\u8868\u793a\u5f62\u5f0f\u3002\u5982\u679c\u5355\u51fb\u7ed9\u5b9a\u7c7b\u578b\u7684\u7bad\u5934\u56fe\u6807\uff0c\u5219\u53ef\u4ee5\u663e\u793a\u6216\u9690\u85cf\u8be5\u7c7b\u578b\u7684\u6210\u5458\u3002\u201c\u7c7b\u56fe\u201d\u4e0b\u65b9\u662f\u201c\u7c7b\u8be6\u7ec6\u4fe1\u606f\u201d\u7a97\u53e3\uff0c\u5176\u4e2d\u663e\u793a\u4e86\u6240\u9009\u7c7b\u56fe\u7684\u7ec6\u8282\uff08\u8bf7\u53c2\u9605\u56fe 2-10\uff09\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/miie.net\/img\/pro-csharp10\/images\/0210.png\" alt=\"Alt text\" \/><\/p>\n<p>Figure 2-10. The Class Diagram viewer<br \/>\n\u56fe 2-10\u3002 \u7c7b\u56fe\u67e5\u770b\u5668<\/p>\n<blockquote><p>\n\u25a0 Note  using the Class Designer toolbar, you can fine-tune the display options of the designer surface.<br \/>\n\u4f7f\u7528\u7c7b\u8bbe\u8ba1\u5668\u5de5\u5177\u680f\uff0c\u53ef\u4ee5\u5fae\u8c03\u8bbe\u8ba1\u5668\u56fe\u9762\u7684\u663e\u793a\u9009\u9879\u3002\n<\/p><\/blockquote>\n<p>The Class Details window not only shows you the details of the currently selected item in the diagram but also allows you to modify existing members and insert new members on the fly.<br \/>\n\u201c\u7c7b\u8be6\u7ec6\u4fe1\u606f\u201d\u7a97\u53e3\u4e0d\u4ec5\u663e\u793a\u5173\u7cfb\u56fe\u4e2d\u5f53\u524d\u9009\u5b9a\u9879\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u8fd8\u5141\u8bb8\u60a8\u4fee\u6539\u73b0\u6709\u6210\u5458\u5e76\u52a8\u6001\u63d2\u5165\u65b0\u6210\u5458\u3002<\/p>\n<p>The Class Designer Toolbox allows you to insert new types (and create relationships between these types) into your project visually (see Figure 2-11). (Be aware you must have a class diagram as the active window to view this toolbox.) As you do so, the IDE automatically creates new C# type definitions in the background.<br \/>\n\u4f7f\u7528\u7c7b\u8bbe\u8ba1\u5668\u5de5\u5177\u7bb1\uff0c\u53ef\u4ee5\u76f4\u89c2\u5730\u5c06\u65b0\u7c7b\u578b\uff08\u5e76\u5728\u8fd9\u4e9b\u7c7b\u578b\u4e4b\u95f4\u521b\u5efa\u5173\u7cfb\uff09\u63d2\u5165\u5230\u9879\u76ee\u4e2d\uff08\u8bf7\u53c2\u89c1\u56fe 2-11\uff09\u3002\uff08\u8bf7\u6ce8\u610f\uff0c\u5fc5\u987b\u5c06\u7c7b\u56fe\u4f5c\u4e3a\u6d3b\u52a8\u7a97\u53e3\u624d\u80fd\u67e5\u770b\u6b64\u5de5\u5177\u7bb1\u3002\u6267\u884c\u6b64\u64cd\u4f5c\u65f6\uff0cIDE \u4f1a\u5728\u540e\u53f0\u81ea\u52a8\u521b\u5efa\u65b0\u7684 C# \u7c7b\u578b\u5b9a\u4e49\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/miie.net\/img\/pro-csharp10\/images\/0211.png\" alt=\"Alt text\" \/><\/p>\n<p>Figure 2-11. The Class Designer Toolbox<br \/>\n\u56fe 2-11\u3002 \u7c7b\u8bbe\u8ba1\u5668\u5de5\u5177\u7bb1<\/p>\n<p>By way of example, drag a new class from the Class Designer Toolbox onto your Class Designer. Name this class Make with public access and select Create new file. This will result in the creation of a new C# file named Make.cs that is automatically added to your project. Now, using the Class Details window, add a public string property named Name (see Figure 2-12).<br \/>\n\u4f8b\u5982\uff0c\u5c06\u4e00\u4e2a\u65b0\u7c7b\u4ece\u201c\u7c7b\u8bbe\u8ba1\u5668\u5de5\u5177\u7bb1\u201d\u62d6\u5230\u201c\u7c7b\u8bbe\u8ba1\u5668\u201d\u4e0a\u3002\u5c06\u6b64\u7c7b\u547d\u540d\u4e3a\u201c\u5177\u6709\u516c\u5171\u8bbf\u95ee\u6743\u9650\u7684 Make\u201d\uff0c\u7136\u540e\u9009\u62e9\u201c\u521b\u5efa\u65b0\u6587\u4ef6\u201d\u3002\u8fd9\u5c06\u5bfc\u81f4\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a Make.cs \u7684\u65b0 C# \u6587\u4ef6\uff0c\u8be5\u6587\u4ef6\u4f1a\u81ea\u52a8\u6dfb\u52a0\u5230\u9879\u76ee\u4e2d\u3002\u73b0\u5728\uff0c\u4f7f\u7528\u201c\u7c7b\u8be6\u7ec6\u4fe1\u606f\u201d\u7a97\u53e3\uff0c\u6dfb\u52a0\u4e00\u4e2a\u540d\u4e3a Name \u7684\u516c\u5171\u5b57\u7b26\u4e32\u5c5e\u6027\uff08\u8bf7\u53c2\u89c1\u56fe 2-12\uff09\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/miie.net\/img\/pro-csharp10\/images\/0212.png\" alt=\"Alt text\" \/><\/p>\n<p>Figure 2-12. Adding a property with the Class Details window<br \/>\n\u56fe 2-12\u3002 \u4f7f\u7528\u201c\u7c7b\u8be6\u7ec6\u4fe1\u606f\u201d\u7a97\u53e3\u6dfb\u52a0\u5c5e\u6027<\/p>\n<p>If you now look at the C# definition of the Make class, you will see it has been updated accordingly:<br \/>\n\u5982\u679c\u73b0\u5728\u67e5\u770b Make \u7c7b\u7684 C# \u5b9a\u4e49\uff0c\u5c06\u770b\u5230\u5b83\u5df2\u76f8\u5e94\u5730\u66f4\u65b0\uff1a<\/p>\n<p><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nnamespace SimpleCSharpConsoleApp\n{\n    public class Make\n    {\n        public int Name\n        {\n            get =&gt; default;\n            set { }\n        }\n    }\n}\n<\/pre>\n<\/p>\n<blockquote><p>\n\u25a0 Note Don\u2019t worry about the extra using statements or the syntax of property. This will all be covered in subsequent chapters.<br \/>\n\u4e0d\u8981\u62c5\u5fc3\u989d\u5916\u7684 using \u8bed\u53e5\u6216\u5c5e\u6027\u8bed\u6cd5\u3002\u8fd9\u4e9b\u90fd\u5c06\u5728\u540e\u7eed\u7ae0\u8282\u4e2d\u4ecb\u7ecd\u3002\n<\/p><\/blockquote>\n<p>Now, activate the designer file once again and drag another new class onto the designer and name it SportsCar. Click the Inheritance icon in the Class Designer Toolbox and click the top of the SportsCar icon. Next, click the mouse on top of the Car class icon. If you performed these steps correctly, you have just derived the SportsCar class from Car (see Figure 2-13).<br \/>\n\u73b0\u5728\uff0c\u518d\u6b21\u6fc0\u6d3b\u8bbe\u8ba1\u5668\u6587\u4ef6\uff0c\u5e76\u5c06\u53e6\u4e00\u4e2a\u65b0\u7c7b\u62d6\u5230\u8bbe\u8ba1\u5668\u4e0a\u5e76\u5c06\u5176\u547d\u540d\u4e3a SportsCar\u3002\u5355\u51fb\u201c\u7c7b\u8bbe\u8ba1\u5668\u5de5\u5177\u7bb1\u201d\u4e2d\u7684\u201c\u7ee7\u627f\u201d\u56fe\u6807\uff0c\u7136\u540e\u5355\u51fb\u8dd1\u8f66\u7684\u9876\u90e8\u56fe\u6807\u3002\u63a5\u4e0b\u6765\uff0c\u5355\u51fb\u6c7d\u8f66\u7c7b\u56fe\u6807\u9876\u90e8\u7684\u9f20\u6807\u3002\u5982\u679c\u6b63\u786e\u6267\u884c\u4e86\u8fd9\u4e9b\u6b65\u9aa4\uff0c\u5219\u521a\u521a\u4ece Car \u6d3e\u751f\u4e86 SportsCar \u7c7b\uff08\u8bf7\u53c2\u9605\u56fe 2-13\uff09\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/miie.net\/img\/pro-csharp10\/images\/0213.png\" alt=\"Alt text\" \/><\/p>\n<p>Figure 2-13. Visually deriving from an existing class<br \/>\n\u56fe 2-13\u3002 \u4ece\u73b0\u6709\u7c7b\u76f4\u89c2\u6d3e\u751f<\/p>\n<blockquote><p>\n\u25a0 Note The concept of inheritance will be fully examined in Chapter 6.<br \/>\n\u6ce8\u610f\u7ee7\u627f\u7684\u6982\u5ff5\u5c06\u5728\u7b2c6\u7ae0\u4e2d\u5168\u9762\u8ba8\u8bba\u3002\n<\/p><\/blockquote>\n<p>To complete this example, update the generated SportsCar class with a public method namedGetPetName(), authored as follows:<br \/>\n\u82e5\u8981\u5b8c\u6210\u6b64\u793a\u4f8b\uff0c\u8bf7\u4f7f\u7528\u540d\u4e3aGetPetName\uff08\uff09\uff0c\u7f16\u5199\u5982\u4e0b\uff1a<\/p>\n<p><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\npublic class SportsCar : Car\n{\n    public string GetPetName()\n    {\n        PetNam&quot; = &quot;&quot;red&quot;;\n        return PetName;\n    }\n}\n\n<\/pre>\n<\/p>\n<p>As you would expect, the designer shows the added method to the SportsCar class.<br \/>\n\u5982\u60a8\u6240\u6599\uff0c\u8bbe\u8ba1\u5668\u663e\u793a\u4e86\u6dfb\u52a0\u5230 SportsCar \u7c7b\u7684\u65b9\u6cd5\u3002<\/p>\n<p>This concludes your first look at Visual Studio. Now let\u2019s look at the most recent addition to the Visual Studio family, Visual Studio Code.<br \/>\n\u4f60\u5bf9Visual Studio\u7684\u7b2c\u4e00\u6b21\u4e86\u89e3\u5230\u6b64\u7ed3\u675f\u3002\u73b0\u5728\u8ba9\u6211\u4eec\u770b\u770bVisual Studio\u7cfb\u5217\u7684\u6700\u65b0\u6210\u5458Visual Studio Code\u3002<\/p>\n<h2>Building .NET Core Applications with Visual Studio Code<\/h2>\n<p>\u4f7f\u7528 Visual Studio Code \u6784\u5efa .NET Core \u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>Another popular IDE from Microsoft is Visual Studio Code (VS Code). Visual Studio Code is a relatively new edition to the Microsoft family; is free, open source, and cross-platform; and has gained significant adoption among developers in and out of the .NET ecosystem. The focus of Visual Studio Code is (as the name suggests) the code of your application. While it does not have many of the built-in features that are included in Visual Studio, it is extremely fast, and additional functionality (like different language support) can be added through extensions. This allows you to have a fast IDE customized for your workflow. Many samples in this book are built and tested with Visual Studio Code. You can download it here:<br \/>\nMicrosoft\u53e6\u4e00\u4e2a\u6d41\u884c\u7684IDE\u662fVisual Studio Code\uff08VS Code\uff09\u3002Visual Studio Code\u662fMicrosoft\u7cfb\u5217\u4e2d\u76f8\u5bf9\u8f83\u65b0\u7684\u7248\u672c;\u514d\u8d39\u3001\u5f00\u6e90\u548c\u8de8\u5e73\u53f0;\u5e76\u5728 .NET \u751f\u6001\u7cfb\u7edf\u5185\u5916\u7684\u5f00\u53d1\u4eba\u5458\u4e2d\u83b7\u5f97\u4e86\u5e7f\u6cdb\u7684\u91c7\u7528\u3002Visual Studio Code \u7684\u91cd\u70b9\u662f\uff08\u987e\u540d\u601d\u4e49\uff09\u5e94\u7528\u7a0b\u5e8f\u7684\u4ee3\u7801\u3002\u867d\u7136\u5b83\u6ca1\u6709Visual Studio\u4e2d\u5305\u542b\u7684\u8bb8\u591a\u5185\u7f6e\u529f\u80fd\uff0c\u4f46\u5b83\u975e\u5e38\u5feb\uff0c\u5e76\u4e14\u53ef\u4ee5\u901a\u8fc7\u6269\u5c55\u6dfb\u52a0\u5176\u4ed6\u529f\u80fd\uff08\u5982\u4e0d\u540c\u7684\u8bed\u8a00\u652f\u6301\uff09\u3002\u8fd9\u5141\u8bb8\u60a8\u4e3a\u5de5\u4f5c\u6d41\u81ea\u5b9a\u4e49\u5feb\u901f IDE\u3002\u672c\u4e66\u4e2d\u7684\u8bb8\u591a\u793a\u4f8b\u90fd\u662f\u4f7f\u7528 Visual Studio Code \u6784\u5efa\u548c\u6d4b\u8bd5\u7684\u3002\u60a8\u53ef\u4ee5\u5728\u6b64\u5904\u4e0b\u8f7d\uff1a<a href=\"https:\/\/code.visualstudio.com\/download\"><a href=\"https:\/\/code.visualstudio.com\/download\"><a href=\"https:\/\/code.visualstudio.com\/download\">https:\/\/code.visualstudio.com\/download<\/a><\/a><\/a><\/p>\n<p>After installing VS Code, you will want to add the C# extension found here:<br \/>\n\u5b89\u88c5 VS Code \u540e\uff0c\u9700\u8981\u6dfb\u52a0\u5728\u6b64\u5904\u627e\u5230\u7684 C# \u6269\u5c55\uff1a<br \/>\n<a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-dotnettools.csharp\"><a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-dotnettools.csharp\"><a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-dotnettools.csharp\">https:\/\/marketplace.visualstudio.com\/items?itemName=ms-dotnettools.csharp<\/a><\/a><\/a><\/p>\n<blockquote><p>\n\u25a0 Note  Visual Studio Code is used to develop many different types of applications based on a multitude of languages. There are extensions for angular, View, php, Java, and many, many, more.<br \/>\n\u6ce8\u610f Visual Studio Code \u7528\u4e8e\u5f00\u53d1\u57fa\u4e8e\u591a\u79cd\u8bed\u8a00\u7684\u8bb8\u591a\u4e0d\u540c\u7c7b\u578b\u7684\u5e94\u7528\u7a0b\u5e8f\u3002\u6709angular\uff0cView\uff0cphp\uff0cJava\u7b49\u6269\u5c55\u3002\n<\/p><\/blockquote>\n<h3>Taking Visual Studio Code for a Test-Drive<\/h3>\n<p>\u4f7f\u7528 Visual Studio \u5199\u4ee3\u7801<\/p>\n<p>Let\u2019s take a quick look at Visual Studio Code by building the same .NET 6 Console application from the Visual Studio example.<br \/>\n\u8ba9\u6211\u4eec\u901a\u8fc7\u4eceVisual Studio\u793a\u4f8b\u6784\u5efa\u76f8\u540c\u7684.NET 6 Console\u5e94\u7528\u7a0b\u5e8f\u6765\u5feb\u901f\u6d4f\u89c8Visual Studio Code\u3002<\/p>\n<h2>Creating Solutions and Projects<\/h2>\n<p>\u521b\u5efa\u89e3\u51b3\u65b9\u6848\u548c\u9879\u76ee<\/p>\n<p>When you start Visual Studio Code, you are presented with a blank slate. Creating solutions and projects must be done through the .NET 6 command-line interface, also known as the CLI. To start, open a folder with Visual Studio Code by selecting File \u27a4 Open Folder, and navigate through the explorer window to where you want your solution and project to live. Next, open a terminal window by selecting Terminal \u27a4 New Terminal or by pressing Ctl+<code>. \u5f53\u4f60\u542f\u52a8Visual Studio Code\u65f6\uff0c\u4f60\u4f1a\u770b\u5230\u4e00\u4e2a\u7a7a\u767d\u7684\u77f3\u677f\u3002\u5fc5\u987b\u901a\u8fc7 .NET 6 \u547d\u4ee4\u884c\u754c\u9762\uff08\u4e5f\u79f0\u4e3a CLI\uff09\u521b\u5efa\u89e3\u51b3\u65b9\u6848\u548c\u9879\u76ee\u3002\u9996\u5148\uff0c\u901a\u8fc7\u9009\u62e9\u201c\u6587\u4ef6\u201d\u27a4\u201c\u6253\u5f00\u6587\u4ef6\u5939\u201d\uff0c\u4f7f\u7528 Visual Studio Code \u6253\u5f00\u6587\u4ef6\u5939\uff0c\u7136\u540e\u5728\u8d44\u6e90\u7ba1\u7406\u5668\u7a97\u53e3\u4e2d\u5bfc\u822a\u5230\u5e0c\u671b\u89e3\u51b3\u65b9\u6848\u548c\u9879\u76ee\u6240\u5728\u7684\u4f4d\u7f6e\u3002\u63a5\u4e0b\u6765\uff0c\u901a\u8fc7\u9009\u62e9\u7ec8\u7aef \u27a4 \u65b0\u5efa\u7ec8\u7aef\u6216\u6309 Ctl+<\/code> \u6253\u5f00\u7ec8\u7aef\u7a97\u53e3\u3002(\u952e\u76d8\u4e0a\u6570\u5b571\u5de6\u8fb9\u7684\u952e)<\/p>\n<p>In the terminal window, enter the following command to create an empty .NET 5 solution file:<br \/>\n\u5728\u7ec8\u7aef\u7a97\u53e3\u4e2d\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u4ee5\u521b\u5efa\u7a7a\u7684 .NET 5 \u89e3\u51b3\u65b9\u6848\u6587\u4ef6\uff1a<\/p>\n<p><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndotnet new sln -n SimpleCSharpConsoleApp -o .\\VisualStudioCode\n<\/pre>\n<\/p>\n<p>This creates a new solution file with the name (-n) SimpleCSharpConsoleApp in a subdirectory (of the current directory) named VisualStudioCode. When using Visual Studio Code with a single project app, there is no need to create a solution file. Visual Studio is solution centric; Visual Studio Code is code centric. We created a solution file here to duplicate the process in the Visual Studio example.<br \/>\n\u8fd9\u5c06\u5728\u540d\u4e3a VisualStudioCode \u7684\u5b50\u76ee\u5f55\uff08\u5f53\u524d\u76ee\u5f55\uff09\u4e2d\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a \uff08-n\uff09 SimpleCSharpConsoleApp \u7684\u65b0\u89e3\u51b3\u65b9\u6848\u6587\u4ef6\u3002\u5c06 Visual Studio Code \u4e0e\u5355\u4e2a\u9879\u76ee\u5e94\u7528\u7a0b\u5e8f\u4e00\u8d77\u4f7f\u7528\u65f6\uff0c\u65e0\u9700\u521b\u5efa\u89e3\u51b3\u65b9\u6848\u6587\u4ef6\u3002Visual Studio\u4ee5\u89e3\u51b3\u65b9\u6848\u4e3a\u4e2d\u5fc3;Visual Studio Code\u4ee5\u4ee3\u7801\u4e3a\u4e2d\u5fc3\u3002\u6211\u4eec\u5728\u6b64\u5904\u521b\u5efa\u4e86\u4e00\u4e2a\u89e3\u51b3\u65b9\u6848\u6587\u4ef6\uff0c\u7528\u4e8e\u590d\u5236 Visual Studio \u793a\u4f8b\u4e2d\u7684\u8fc7\u7a0b\u3002<\/p>\n<blockquote><p>\n\u25a0 Note  These examples use the Windows directory separators. adjust the separators based on your operating system.<br \/>\n\u8fd9\u4e9b\u793a\u4f8b\u4f7f\u7528 Windows \u76ee\u5f55\u5206\u9694\u7b26\u3002 \u6839\u636e\u60a8\u7684\u64cd\u4f5c\u7cfb\u7edf\u8c03\u6574\u5206\u9694\u7b26\u3002\n<\/p><\/blockquote>\n<p>Next, create a new C# 9\/.NET 5 (-f net6.0) console application named (-n) SimpleCSharpConsoleApp in a subdirectory (-o) of the same name (note that this command must be all on one line):<br \/>\n\u63a5\u4e0b\u6765\uff0c\u5728\u540c\u540d\u7684\u5b50\u76ee\u5f55 \uff08-o\uff09 \u4e2d\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a \uff08-n\uff09 \u7684 SimpleCSharpConsoleApp \u7684\u65b0 C# 9\/.NET 5 \uff08-f net6.0\uff09 \u63a7\u5236\u53f0\u5e94\u7528\u7a0b\u5e8f\uff08\u8bf7\u6ce8\u610f\uff0c\u6b64\u547d\u4ee4\u5fc5\u987b\u5168\u90e8\u5728\u4e00\u884c\u4e0a\uff09\uff1a<\/p>\n<p><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndotnet new console -lang c# -n SimpleCSharpConsoleApp -o .\\VisualStudioCode\\ SimpleCSharpConsoleApp -f net6.0\n<\/pre>\n<\/p>\n<p>Finally, add the newly created project to the solution with the following command:<br \/>\n\u6700\u540e\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5c06\u65b0\u521b\u5efa\u7684\u9879\u76ee\u6dfb\u52a0\u5230\u89e3\u51b3\u65b9\u6848\u4e2d\uff1a<\/p>\n<p><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndotnet sln .\\VisualStudioCode\\SimpleCSharpConsoleApp.sln add .\\VisualStudioCode\\ SimpleCSharpConsoleApp\n<\/pre>\n<\/p>\n<blockquote><p>\n\u25a0 Note  This is just a small sample of what the ClI is capable of. To discover everything the ClI can do, enter dotnet -h.<br \/>\n\u8fd9\u53ea\u662f ClI \u529f\u80fd\u7684\u4e00\u5c0f\u90e8\u5206\u793a\u4f8b\u3002\u8981\u4e86\u89e3 ClI \u53ef\u4ee5\u6267\u884c\u7684\u6240\u6709\u64cd\u4f5c\uff0c\u8bf7\u8f93\u5165dotnet -h.\n<\/p><\/blockquote>\n<h2>Exploring the Visual Studio Code Workspace<\/h2>\n<p>\u63a2\u7d22 Visual Studio Code Workspace<\/p>\n<p>As you can see in Figure 2-14, the Visual Studio Code workspace is focused on the code, but also provides a lot of additional features to aid your productivity. The explorer (1) is an integrated file explorer andis selected in the figure. The Source Control (2) integrates with Git. The Debug icon (3) launches the appropriate debugger (once the correct extension is installed). The next one down is the extension manager (4). The extension manager is context sensitive and will make recommendations based on the type of code in the open directory and subdirectories.<br \/>\n\u5982\u56fe 2-14 \u6240\u793a\uff0cVisual Studio Code \u5de5\u4f5c\u533a\u4fa7\u91cd\u4e8e\u4ee3\u7801\uff0c\u4f46\u4e5f\u63d0\u4f9b\u4e86\u8bb8\u591a\u9644\u52a0\u529f\u80fd\u6765\u5e2e\u52a9\u63d0\u9ad8\u5de5\u4f5c\u6548\u7387\u3002\u8d44\u6e90\u7ba1\u7406\u5668 \uff081\uff09 \u662f\u4e00\u4e2a\u96c6\u6210\u7684\u6587\u4ef6\u6d4f\u89c8\u5668\u548c\u5728\u56fe\u4e2d\u88ab\u9009\u4e2d\u3002\u6e90\u4ee3\u7801\u7ba1\u7406 \uff082\uff09 \u4e0e Git \u96c6\u6210\u3002\u8c03\u8bd5\u56fe\u6807 \uff083\uff09 \u542f\u52a8\u76f8\u5e94\u7684\u8c03\u8bd5\u5668\uff08\u5b89\u88c5\u6b63\u786e\u7684\u6269\u5c55\u540e\uff09\u3002\u4e0b\u4e00\u4e2a\u662f\u6269\u5c55\u7ba1\u7406\u5668 \uff084\uff09\u3002\u6269\u5c55\u7ba1\u7406\u5668\u4e0e\u4e0a\u4e0b\u6587\u76f8\u5173\uff0c\u5c06\u6839\u636e\u6253\u5f00\u76ee\u5f55\u548c\u5b50\u76ee\u5f55\u4e2d\u7684\u4ee3\u7801\u7c7b\u578b\u63d0\u51fa\u5efa\u8bae\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/miie.net\/img\/pro-csharp10\/images\/0214.png\" alt=\"Alt text\" \/><\/p>\n<p>Figure 2-14. The Visual Studio Code workspace<br \/>\n\u56fe 2-14\u3002 Visual Studio Code \u5de5\u4f5c\u533a<\/p>\n<p>The code editor (5) is complete with color coding and IntelliSense support. The code map (6) shows the map of your entire code file, and the Problems\/Output\/Debug Console\/Terminal window (7) receives the output from debug sessions and accepts input from the user.<br \/>\n\u4ee3\u7801\u7f16\u8f91\u5668 \uff085\uff09 \u5177\u6709\u989c\u8272\u7f16\u7801\u548c\u667a\u80fd\u611f\u77e5\u652f\u6301\u3002\u4ee3\u7801\u56fe \uff086\uff09 \u663e\u793a\u6574\u4e2a\u4ee3\u7801\u6587\u4ef6\u7684\u6620\u5c04\uff0c\u95ee\u9898\/\u8f93\u51fa\/\u8c03\u8bd5\u63a7\u5236\u53f0\/\u7ec8\u7aef\u7a97\u53e3 \uff087\uff09 \u63a5\u6536\u6765\u81ea\u8c03\u8bd5\u4f1a\u8bdd\u7684\u8f93\u51fa\u5e76\u63a5\u53d7\u6765\u81ea\u7528\u6237\u7684\u8f93\u5165\u3002<\/p>\n<h2>Restoring Packages, Building and Running Programs<\/h2>\n<p>\u6062\u590d\u5305\uff0c\u6784\u5efa\u548c\u8fd0\u884c\u7a0b\u5e8f<\/p>\n<p>The .NET 6 CLI has all of the power needed to create and build solutions and projects, add and restore NuGet packages, and run applications. To restore all of the NuGet packages required for your solution and project, enter the following command in the terminal window (or a command window outside of VS Code), making sure to run the command from the same directory as the solution file:<br \/>\n.NET 6 CLI \u5177\u6709\u521b\u5efa\u548c\u751f\u6210\u89e3\u51b3\u65b9\u6848\u548c\u9879\u76ee\u3001\u6dfb\u52a0\u548c\u8fd8\u539f NuGet \u5305\u4ee5\u53ca\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\u6240\u9700\u7684\u6240\u6709\u529f\u80fd\u3002\u82e5\u8981\u8fd8\u539f\u89e3\u51b3\u65b9\u6848\u548c\u9879\u76ee\u6240\u9700\u7684\u6240\u6709 NuGet \u5305\uff0c\u8bf7\u5728\u7ec8\u7aef\u7a97\u53e3\uff08\u6216 VS Code \u5916\u90e8\u7684\u547d\u4ee4\u7a97\u53e3\uff09\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff0c\u786e\u4fdd\u4ece\u4e0e\u89e3\u51b3\u65b9\u6848\u6587\u4ef6\u76f8\u540c\u7684\u76ee\u5f55\u8fd0\u884c\u547d\u4ee4\uff1a<\/p>\n<p><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndotnet restore\n<\/pre>\n<\/p>\n<blockquote><p>\n\u25a0 Note using dotnet build also restores all of the nuget packages.<br \/>\n\u4f7f\u7528 dotnet \u751f\u6210\u8fd8\u4f1a\u8fd8\u539f\u6240\u6709 nuget \u5305\u3002\n<\/p><\/blockquote>\n<p>To restore and build all of the projects in your solution, execute the following in the terminal\/command window (again, making sure the command is executed in the same directory as the solution file):<br \/>\n\u82e5\u8981\u8fd8\u539f\u548c\u751f\u6210\u89e3\u51b3\u65b9\u6848\u4e2d\u7684\u6240\u6709\u9879\u76ee\uff0c\u8bf7\u5728\u7ec8\u7aef\/\u547d\u4ee4\u7a97\u53e3\u4e2d\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff08\u518d\u6b21\u786e\u4fdd\u547d\u4ee4\u5728\u4e0e\u89e3\u51b3\u65b9\u6848\u6587\u4ef6\u76f8\u540c\u7684\u76ee\u5f55\u4e2d\u6267\u884c\uff09\uff1a<\/p>\n<p><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndotnet build\n<\/pre>\n<\/p>\n<blockquote><p>\n\u25a0 Note When dotnet restore and dotnet build are executed in a directory that contains a solution file, all of the projects in the solution are acted on. The commands can also be run on a single project by running the command in the directory of the C# project file (<em>.csproj).<br \/>\n\u5728\u5305\u542b\u89e3\u51b3\u65b9\u6848\u6587\u4ef6\u7684\u76ee\u5f55\u4e2d\u6267\u884c dotnet \u8fd8\u539f\u548c dotnet \u751f\u6210\u65f6\uff0c\u5c06\u6267\u884c\u89e3\u51b3\u65b9\u6848\u4e2d\u7684\u6240\u6709\u9879\u76ee\u3002\u8fd8\u53ef\u4ee5\u901a\u8fc7\u5728 C# \u9879\u76ee\u6587\u4ef6 \uff08<\/em>.csproj\uff09 \u7684\u76ee\u5f55\u4e2d\u8fd0\u884c\u547d\u4ee4\u6765\u5728\u5355\u4e2a\u9879\u76ee\u4e0a\u8fd0\u884c\u8fd9\u4e9b\u547d\u4ee4\u3002\n<\/p><\/blockquote>\n<p>To run your project without debugging, execute the following .NET CLI command in the same directory as the project file (SimpleCSharpConsoleApp.csproj):<br \/>\n\u82e5\u8981\u5728\u4e0d\u8c03\u8bd5\u7684\u60c5\u51b5\u4e0b\u8fd0\u884c\u9879\u76ee\uff0c\u8bf7\u5728\u4e0e\u9879\u76ee\u6587\u4ef6 \uff08SimpleCSharpConsoleApp.csproj\uff09 \u76f8\u540c\u7684\u76ee\u5f55\u4e2d\u6267\u884c\u4ee5\u4e0b .NET CLI \u547d\u4ee4\uff1a<\/p>\n<p><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndotnet run\n<\/pre>\n<\/p>\n<h2>Debugging Your Project<\/h2>\n<p>\u8c03\u8bd5\u9879\u76ee<\/p>\n<p>To debug your program after setting a break point, click the Debug icon (2 in Figure 2-14), then click Run and Debug (Figure 2-15).<br \/>\n\u82e5\u8981\u5728\u8bbe\u7f6e\u65ad\u70b9\u540e\u8c03\u8bd5\u7a0b\u5e8f\uff0c\u8bf7\u5355\u51fb\u201c\u8c03\u8bd5\u201d\u56fe\u6807\uff08\u56fe 2-2 \u4e2d\u7684 14\uff09\uff0c\u7136\u540e\u5355\u51fb\u201c\u8fd0\u884c\u548c\u8c03\u8bd5\u201d\uff08\u56fe 2-15\uff09\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/miie.net\/img\/pro-csharp10\/images\/0215.png\" alt=\"Alt text\" \/><\/p>\n<p>Figure 2-15. Run and Debug in Visual Studio Code<br \/>\n\u56fe 2-15\u3002 \u5728 Visual Studio Code \u4e2d\u8fd0\u884c\u548c\u8c03\u8bd5<\/p>\n<h2>Finding the .NET Core and C# Documentation<\/h2>\n<p>\u67e5\u627e .NET Core \u548c C# \u6587\u6863<\/p>\n<p>The C# and .NET Core documentation are both extremely good, very readable, and full of useful information. Given the huge number of predefined .NET types (which number well into the thousands), you must be willing to roll up your sleeves and dig into the provided documentation. You can view all of the Microsoft documentation here:<br \/>\nC# \u548c .NET Core \u6587\u6863\u90fd\u975e\u5e38\u597d\uff0c\u975e\u5e38\u6613\u8bfb\uff0c\u5e76\u4e14\u5145\u6ee1\u4e86\u6709\u7528\u7684\u4fe1\u606f\u3002\u9274\u4e8e\u9884\u5b9a\u4e49\u7684 .NET \u7c7b\u578b\u6570\u91cf\u5e9e\u5927\uff08\u6570\u91cf\u8fbe\u5230\u6570\u5343\u79cd\uff09\uff0c\u60a8\u5fc5\u987b\u613f\u610f\u5377\u8d77\u8896\u5b50\u5e76\u6df1\u5165\u7814\u7a76\u63d0\u4f9b\u7684\u6587\u6863\u3002\u60a8\u53ef\u4ee5\u5728\u6b64\u5904\u67e5\u770b\u6240\u6709Microsoft\u6587\u6863\uff1a<br \/>\n<a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/csharp\/\"><a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/csharp\/\"><a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/csharp\/\">https:\/\/docs.microsoft.com\/en-us\/dotnet\/csharp\/<\/a><\/a><\/a><\/p>\n<p>The areas that you will use the most in the first half of this book are the C# documentation and the .NET Core documentation, found at the following locations:<br \/>\n\u5728\u672c\u4e66\u7684\u524d\u534a\u90e8\u5206\uff0c\u60a8\u5c06\u4f7f\u7528\u6700\u591a\u7684\u533a\u57df\u662f C# \u6587\u6863\u548c .NET Core \u6587\u6863\uff0c\u5b83\u4eec\u4f4d\u4e8e\u4ee5\u4e0b\u4f4d\u7f6e\uff1a<a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/csharp\/\"><a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/csharp\/\"><a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/csharp\/\">https:\/\/docs.microsoft.com\/en-us\/dotnet\/csharp\/<\/a><\/a><\/a> <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/core\/\"><a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/core\/\"><a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/core\/\">https:\/\/docs.microsoft.com\/en-us\/dotnet\/core\/<\/a><\/a><\/a><\/p>\n<h2>Summary<\/h2>\n<p>\u603b\u7ed3<\/p>\n<p>The point of this chapter was to provide you the information to set up your development environment with the .NET 6 SDK and runtimes as well as provide a tour of Visual Studio 2022 Community Edition and Visual Studio Code. If you are interested in building cross-platform .NET Core applications, you have a host of choices. Visual Studio (Windows only), Visual Studio for the Mac (Mac only), and Visual Studio Code (cross platform) are all supplied by Microsoft. Building WPF or WinForms applications still requires Visual Studio on a Windows machine.<br \/>\n\u672c\u7ae0\u7684\u8981\u70b9\u662f\u4e3a\u60a8\u63d0\u4f9b\u4f7f\u7528 .NET 6 SDK \u548c\u8fd0\u884c\u65f6\u8bbe\u7f6e\u5f00\u53d1\u73af\u5883\u7684\u4fe1\u606f\uff0c\u5e76\u63d0\u4f9b Visual Studio 2022 \u793e\u533a\u7248\u548c Visual Studio \u4ee3\u7801\u7684\u6559\u7a0b\u3002\u5982\u679c\u60a8\u5bf9\u6784\u5efa\u8de8\u5e73\u53f0\u7684 .NET Core \u5e94\u7528\u7a0b\u5e8f\u611f\u5174\u8da3\uff0c\u5219\u6709\u5f88\u591a\u9009\u62e9\u3002Visual Studio\uff08\u4ec5\u9650Windows\uff09\uff0cVisual Studio for the Mac\uff08\u4ec5\u9650Mac\uff09\u548cVisual Studio Code\uff08\u8de8\u5e73\u53f0\uff09\u5747\u7531Microsoft\u63d0\u4f9b\u3002\u6784\u5efaWPF\u6216WinForms\u5e94\u7528\u7a0b\u5e8f\u4ecd\u7136\u9700\u8981\u5728Windows\u673a\u5668\u4e0a\u6784\u5efaVisual Studio\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>CHAPTER 2 Building C# Applications \u6784\u5efa C# \u5e94\u7528\u7a0b\u5e8f Building C# Applications \u6784\u5efa C# \u5e94\u7528\u7a0b\u5e8f As a C# programmer, you can choose from among numerous tools to build .NET Core applications. The tool (or tools) you select will be based primarily on three factors: any associated costs, the OS you are using to develop the software, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[22],"class_list":["post-280","post","type-post","status-publish","format-standard","hentry","category-csharp","tag-pro-csharp10-with-net6"],"_links":{"self":[{"href":"https:\/\/diji.net\/index.php?rest_route=\/wp\/v2\/posts\/280","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/diji.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/diji.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/diji.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/diji.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=280"}],"version-history":[{"count":0,"href":"https:\/\/diji.net\/index.php?rest_route=\/wp\/v2\/posts\/280\/revisions"}],"wp:attachment":[{"href":"https:\/\/diji.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=280"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/diji.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=280"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/diji.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=280"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}