day01——22_9_22

107 阅读1分钟

C#

安装 Visual Studio

image.png

运行第一个 hello world 程序

using System;

namespace demo01
{
    // 创建一个类
    class Progame
    {
 
        static void Main(string[] args)
        {
            Console.WriteLine("hello world");
        }
    }
}

image.png

练习 打印等腰三角形

C# 编译过程

image.png

快捷键使用

打开解决方案:Ctrl+Alt+l(视图里打开)
换行: ctrl + enter    ;   shift+enter
格式化 ctrl+k+d
运行 ctrl + F5
单行注释 : ctrl+k+c
多行注释:ctrl+shift+/

ctrl + backspace 删除
ctrl + del 删除

变量

与java相一致

常量

使用 const修饰

const int i = 1;

基本数据类型

image.png

整数 / 整数 = 整数 (取整)
整数 / 浮点数 = 整数(除尽)/ 浮点数(未整除)

自增、自减

++在前,先++, ++在后,后++;

C++、C#区别

// 创建命名空间
namespace demo01
{
    // 创建一个类
    class Progame
    {
        // 创建一个方法 主函数Main
        static void Main(string[] args)
        {
            Console.WriteLine("hello");
        }
    }
}

#include<iostream>

using namespace std;

int main()
{
    cout << "hello" << endl;
    return 0;
}