一、新建項目
sln:解決方案
csproj:C shap peoject
cs:class
解決方案包含項目,項目包含類。
方法又稱作函數
二、程序構成
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//using xxxx 命名空間
namespace lesson01 //項目名稱
{
class Program //類
{
static void Main(string[] args) //main函數又叫main方法,程序的主入口,起始於main,結束於main
{
}
}
}
三、項目
3.1 設置啓動項
方法一:解決方案屬性中更改
方法二:項目右鍵
3.2 項目的刪除和卸載
四、C#的註釋
4.1 行註釋 (//雙斜線)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//using xxxx 命名空間
//使用using語句導入命名空間時需要將其放在程序的開頭。
4.2 多行註釋(/* */)
/*
* 第一個程序
* 註釋下
*/
namespace lesson01 //項目名稱
{
class Program //類
{
static void Main(string[] args) //main函數又叫main方法,程序的主入口,起始於main,結束於main
{
Console.WriteLine("第一個C#程序");
Console.ReadKey();
}
}
}
4.3 文檔註釋(///)
namespace lesson01 //項目名稱
{
class Program //類
{
/// <summary>
/// 隨便註釋下
/// </summary>
/// <param name="args"></param>
static void Main(string[] args) //main函數又叫main方法,程序的主入口,起始於main,結束於main
{
Console.WriteLine("第一個C#程序");
Console.ReadKey();
}
}
}
專門用來解釋類或者方法
五、VS的快捷鍵
5.1 快速對齊
CTRL+K,只釋放K,快速按下D
5.2 快速智能提示
Ctrl+J
5.3 行操作
ctrl+home :行起始
ctrl+end :行尾巴
shift+home :光標位於行尾後按快捷鍵,選擇整行
5.4 註釋取消
5.5 代碼摺疊
# region
#endregion
namespace lesson01 //項目名稱
{
class Program //類
{
/// <summary>
/// 隨便註釋下
/// </summary>
/// <param name="args"></param>
static void Main(string[] args) //main函數又叫main方法,程序的主入口,起始於main,結束於main
{
Console.WriteLine("第一個C#程序");
Console.WriteLine("第一個C#程序");
#region
Console.WriteLine("第一個C#程序");
Console.WriteLine("第一個C#程序");
#endregion
Console.ReadKey();
}
}
}
5.6 其它
保存:ctrl + S
撤銷:ctrl + Z