文章目录
学前入门
.Net平台 .Net FrameWork框架
.Net FrameWork框架提供了一个稳定的运行环境,;来保障我们.Net平台正常的运转。
两种交互模式
- C/S:要求客户的电脑上必须要安装一个客户端:qq、360、快播等…winform应用程序。
- B/S:要求客户的电脑上只需要安装一个浏览器。Internet应用程序。
两行小代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _01My_First_Demo
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World");//要打印的内容
Console.ReadKey();//暂停当前程序,等待用户按下任意键,按下的任意键将显示在我们的控制台中
}
}
}
结果:
Hello World
基础语法
VS中的快捷键
Ctrl+End :光标跳转到一行代码的尾部
Ctrl+Home :光标跳转到一行代码的首部
Shift+Home/End/上键/下键 :选中一行代码
Ctrl+K+D :快速对齐代码
#region #endregion :折叠冗余代码
变量的类型
整型:int
小数:double 小数点后面的位数 15~16位
字符串:string 也可以存储空 双引号引起来 (C语言中没有字符串这种数据类型)
字符:char 字符类型不能为空 单引号引起来
金钱类型:decimal 复制后其后面得跟m
强制类型转换:(待转换的类型)要转换的值
double d = 303.6;
int n=(int) d;
变量的命名:字母,下划线,数字,但不能以数字开头
两个命名规范:
- Camel 骆驼命名规范。要求变量名首单词的首字母要小写,其余每个单词的首字母要大写。多用于给变量命名。highSchoolStudent
- Pascal 命名规范:要求每个单词的首字母都要大写,其余字母小写。多用于给类或者方法命名。HighSchoolStudent
占位符
C#中的占位符使用("{0}{1}",a,b)…表示
示例:
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)
{
string name = "卡卡西";
int age = 30;