C#-Visual Studio 2017安装与使用
Visual Studio 2017
Visual Studio 2017 适用于开发Android、iOS、Windows、Web和云的应用,支持创建.NET Core程序。
安装Visual Studio 2017
- 从微软官网下载安装文件 visual_studio_professional_2017_x86_x64.exe。这只是一个引导程序(Web Installer)。
-
若已下载visual studio 2017,但不确定是否安装所需组件(通用Windows平台开发、.NET桌面开发、ASP.NET和Web开发)时具体步骤如下:
打开Visual Studio Installer→点开更多,选择修改→进入工作负载选择界面
创建项目
文件→新建→项目
相关文件介绍
- .sln:解决方案文件
- .csproj:项目文件
- .cs:C#源码文件
- bin:项目编译后的输出
- obj:编译时产生的中间文件
- AssemblyInfo.cs:程序本版、信息、版权的属性文件
命名空间
System.Console.WriteLine(“Hello World!”);
使用 using System 后,上述语句变为 Console.WriteLine(“Hello World!”);快捷键
F5 :运行
F11:逐行执行案例分析与实现
要求:
- 显示 输入姓名;
- 接收用户输入的姓名;
- 控制台输出。
关键
- 显示:Console.WriteLine()
- 接收用户输入:Console.ReadLine()
代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("please input your name:");
string name = Console.ReadLine();
Console.WriteLine("Hello {0},welcome come to the world of C#", name);
Console.ReadKey(); //wait for keyboard input,exit the program
}
}
}
运行结果