基础篇2 数字类型

  • 学习阅读代码并尝试修改代码 相关文档 b站视频目前进度为32

  • 学会数字类型的使用可以防止资源的浪费,比如100m就可以完成的代码,如果用long的整数类型会浪费电脑资源(文件会变得更大);

  • 1个字节就是8位

  • 在c#有一种类型为bool型,它是逻辑库,顾名思义就是true and false,可执行逻辑代码。

	bool check = true;
		
Console.WriteLine(check ? "Checked" : "Not checked");  // output: Checked
		
Console.WriteLine(false ? "Checked" : "Not checked");  // output: Not checked
  • 在c#有一个类型为 var ,它是可以自动识别你的等号后面是什么类型并自动转换成该类型。

    var <– c#网址

  • 右边是关于函数的相关信息 函数文档

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    public Add(int x, int y, int z)
    {
    return x+y+z; //使用return返回已经计算好的数值到Add上,相当于输出到Add的数值。
    }

    //如何使用该函数
    //直接使用Add
    Add(1,2,3);
    //或者
    int num = Add(a,b,c);
    int a,b,c;
    a=1;
    b=2;
    c=3;
    //也可以直接在 Add加数字
    Add(a,b,3+c);

    测试测试,这串文字是否上传到我的博客

  • Copyrights © 2022-2026 Jessy Huang
  • Visitors: | Views:

请我喝杯咖啡吧~