当前位置:网站首页>.NET应用程序--Helloworld(C#)
.NET应用程序--Helloworld(C#)
2022-08-05 02:58:00 【DXB2021】
安装 .NET 并创建首个应用程序。
下载.NET SDK(软件开发安装包)
打开Windows PowerShell,输入命令行dotnet。
dotnet
运行结果如下:
如果安装成功,则会看到类似于以上内容的输出。
创建应用:
在命令提示符下,运行以下命令以创建应用:
dotnet new console -o MyApp -f net6.0
然后导航到由上一个命令创建的新目录:
cd MyApp
这些命令分别代表什么?
dotnet new console
命令将为你新建控制台应用。-o
参数会创建名为MyApp
的目录,用于存储应用并使用所需文件进行填充。-f
参数指示你正在创建 .NET 6 应用程序。- 命令
cd MyApp
会将当前目录更改为刚为新应用创建的目录。
Windows PowerShell的代码如下:
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows
PS C:\Users\a-xiaobodou\OneDrive - Microsoft\Projects\C#> dotnet new console -o MyApp -f net6.0
欢迎使用 .NET 6.0!
---------------------
SDK 版本: 6.0.302
遥测
---------
.NET 工具会收集用法数据,帮助我们改善你的体验。它由 Microsoft 收集并与社区共享。你可通过使用喜欢的 shell 将 DOTNET_CLI_TELEMETRY_OPTOUT 环境变量设置为 "1" 或 "true" 来选择退出遥测。
阅读有关 .NET CLI 工具遥测的更多信息: https://aka.ms/dotnet-cli-telemetry
----------------
已安装 ASP.NET Core HTTPS 开发证书。
若要信任该证书,请运行 "dotnet dev-certs https --trust" (仅限 Windows 和 macOS)。
了解 HTTPS: https://aka.ms/dotnet-https
----------------
编写你的第一个应用: https://aka.ms/dotnet-hello-world
查找新增功能: https://aka.ms/dotnet-whats-new
浏览文档: https://aka.ms/dotnet-docs
在 GitHub 上报告问题和查找源: https://github.com/dotnet/core
使用 "dotnet --help" 查看可用命令或访问: https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------
已成功创建模板“控制台应用”。
正在处理创建后操作...
在 C:\Users\a-xiaobodou\OneDrive - Microsoft\Projects\C#\MyApp\MyApp.csproj 上运行 “dotnet restore”...
正在确定要还原的项目…
已还原 C:\Users\a-xiaobodou\OneDrive - Microsoft\Projects\C#\MyApp\MyApp.csproj (用时 122 ms)。
已成功还原。
PS C:\Users\a-xiaobodou\OneDrive - Microsoft\Projects\C#> cd MyApp
PS C:\Users\a-xiaobodou\OneDrive - Microsoft\Projects\C#\MyApp> notepad
PS C:\Users\a-xiaobodou\OneDrive - Microsoft\Projects\C#\MyApp> notepad Program.cs
PS C:\Users\a-xiaobodou\OneDrive - Microsoft\Projects\C#\MyApp>
Program.cs的代码如下:
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
运行应用:
在命令提示符下,运行以下命令:
dotnet run
编辑代码:
Program.cs的代码如下:
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
Console.WriteLine("The current time is "+DateTime.Now);
恭喜已生成并运行自己第一个 .NET 应用!
边栏推荐
- Question about #sql shell#, how to solve it?
- C student management system Insert the student node at the specified location
- 程序员的七夕浪漫时刻
- 采用redis缓存的linux主从同步服务器图片硬盘满了移到新目录要修改哪些指向
- nodeJs--encapsulate routing
- Note that Weifang generally needs to pay attention to issuing invoices
- Linux下常见的开源数据库,你知道几个?
- 数学-求和符号的性质
- 基于左序遍历的数据存储实践
- DAY22: sqli-labs shooting range clearance wp (Less01~~Less20)
猜你喜欢
QT语言文件制作
剑指offer专项突击版第20天
nodeJs--encapsulate routing
Intersection of Boolean Operations in SuperMap iDesktop.Net - Repairing Complex Models with Topological Errors
shell语句修改txt文件或者sh文件
链表的简单描述及代码的简单实现
数据增强Mixup原理与代码解读
In 2022, you still can't "low code"?Data science can also play with Low-Code!
通过模拟Vite一起深入其工作原理
word分栏小记
随机推荐
How Jin Cang database correctness verification platform installation file
UOS系统下ksql应用缺少动态库”libtinfo.so.5“问题
C student management system Insert the student node at the specified location
Common hardware delays
Everyone in China said data, you need to focus on core characteristic is what?
mysql没法Execute 大拿们求解
VSCode Change Default Terminal how to modify the Default Terminal VSCode
1484. 按日期分组销售产品
Talking about data security governance and privacy computing
注意潍坊开具发票一般需要注意
22-07-31周总结
lua学习
mysql tree structure query problem
QT: The Magical QVarient
The 20th day of the special assault version of the sword offer
The problem of lack of dynamic library "libtinfo.so.5" in ksql application under UOS system
2022了你还不会『低代码』?数据科学也能玩转Low-Code啦!
Question about #sql shell#, how to solve it?
1667. Fix names in tables
A small tool to transfer files using QR code - QFileTrans 1.2.0.1