.lsn .csproj
sln: solusion 解决方案
csproj: c sharp project C#项目
解决方案是项目的集合,项目是文件的集合;一个sln中可以包含多个csproj。一个csproj可以包含多个文件;csproj可以作为单独的项目运行,也可以在sln中添加csproj统一管理
=============================================================================================
文档注释.
/// <summary>
///
/// </summary>
在一个类,方法或属性定义的上一行输入///就会出现<summary>. 调用这个类或方法时写在<summary>里的东西就会以提示的方式出现。
=============================================================================================
屏幕显示
using System; //using 关键字用于在程序中包含 System 命名空间
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Project1 //命名空间,一个namespace是一系列的类
{
class Class1
{
static void Main(String[] args)
{
int a = 5;
int b = 2;
Console.WriteLine("a={0},b={1}",a,b); //屏幕上显示消息
Console.ReadKey(); //防止程序从 Visual Studio .NET 启动时屏幕会快速运行并关闭
}
}
}
=============================================================================================
5、C# string 字符串的前面可以加 @(称作"逐字字符串")将转义字符(\)当作普通字符对待,比如:
string str = @"C:\Windows"; <=====> string str = "C:\\Windows";
@ 字符串中可以任意换行,换行符及缩进空格都计算在字符串长度之内
=============================================================================================
6、用户输入
using System;
namespace DeclaringConstants
{
class Program
{
static void Main(string[] args)
{
int num;
num = Convert.ToInt32(Console.ReadL