31948人加入学习
(86人评价)
C#编程-第一季-编程基础-宇宙最简单2021最新版

制作完成于2021年10月10日,使用Visual Studio 2019

价格 免费

.net framework形式的控制台需要在第一个“}”上一行加入“Console.ReadKey();”的代码后,启动后的窗口就不会自动关闭

[展开全文]

类型     描述                    范围                      默认值
bool    布尔值         True 或 False                  False
byte    8 位无符号整数    0 到 255                  0
char    16 位 Unicode 字符    U +0000 到 U +ffff                                                                          '\0'
decimal    128 位精确的十进制值,28-29 有效位数      (-7.9 x 1028 到 7.9 x 1028) / 100 到 28                                                                            0.0M
double    64 位双精度浮点型    (+/-)5.0 x 10-324 到 (+/-)1.7 x 10308                                      0.0D
float    32 位单精度浮点型    -3.4 x 1038 到 + 3.4 x 1038                                                              0.0F
int    32 位有符号整数类型    -2,147,483,648 到 2,147,483,647                                                 0
long    64 位有符号整数类型    -9,223,372,036,854,775,808 到 9,223,372,036,854,775,807                             0L
sbyte    8 位有符号整数类型    -128 到 127       0
short    16 位有符号整数类型    -32,768 到 32,767                                                                            0
uint    32 位无符号整数类型    0 到 4,294,967,295                                                                             0
ulong    64 位无符号整数类型    0 到 18,446,744,073,709,551,615                              0
ushort    16 位无符号整数类型    0 到 65,535    0

[展开全文]

函数可以直接放在结构体里面,

因为可以直接访问当前结构体内的值,所以就不需要形参;

[展开全文]

using。。

命名空间。。

        类

              方法

                     代码

[展开全文]

convert toint32()

console readlne()

输入

[展开全文]
 public class Vector
    {

        static void Main(string[] args)
        {

            Week day=Week.Mon;
            Console.WriteLine(day);
            //强转后可以查询enum中枚举类型的值
            //如Week.Mon为1
            int number=(int)day;
        }
        
        enum Week
        {
        //  0  ,1  ,2  ,3  ,4  ,5  ,6
            Sun,Mon,Tue,Wed,Thu,Fri,Sat
        }
        enum Week2
          {
        //  0  ,1  ,2  ,10,11 ,100    ,101,102
            Sun,Mon,Tue=10,Wed,Thu=100,Fri,Sat
        }
    }
```

 

[展开全文]


            char c;
            int sum = 0;
            do
            {
                c = (char)Console.Read();
                if (c >= '0' & c <= '9')
                {
                    int num = c - '0';
                    sum += num;
                }
                else if(c=='*')
                    {
                    sum += 500;
                }

            } while (c!='#');

            Console.WriteLine(sum);

[展开全文]

 int num = Convert.ToInt32(Console.ReadLine());
            int i = 0;
            int x=0;
            int sum = 1;
            int y = num;
            int z = num;
            while (num != 0)
            {
               
                 i = num % 10;
              
                sum *= 10;
                num /= 10;
            }
            while (y != 0)
            {
                sum /= 10;
                i = y % 10;
                x = i * sum + x;
                
               y /= 10;
            }
            if (x == z)
                Console.WriteLine("yes");
            else
                Console.WriteLine("no");
 

[展开全文]

 int num = Convert.ToInt32(Console.ReadLine());
      

          
               while( num % 10==0)
                { num /= 10; 
                }
              
               
               while(num!=0)
                {
                    int i = num % 10;
                Console.Write(i);
                    num /= 10;
                }

[展开全文]


            double qiu = Convert.ToDouble(Console.ReadLine());
            double sum = 0.0;
            double a = qiu;
            for (int i = 0; i <10; i++)
            {
                sum = qiu * 2.0 + sum;
                qiu =qiu/ 2.0;
                

            }
            Console.WriteLine(qiu);
            Console.WriteLine((sum-a));

[展开全文]

ctrl+k   crtl+c   出现双斜杠

ctrl+k   ctrl+u   取消双斜杠

[展开全文]

//单行注释

 

/*多行注释

多行

多行

*/ 

 

main方法

 

注释 ctrl+k+ctrl+c

取消注释  ctrl+k ctrl+u

[展开全文]

int n = Convert.ToInt32(Console.ReadLine());
            int i = 0;
            while (n != 1) 
            {
                if (n % 2 == 1)
                    n = 3 * n + 1;
                else
                    n = n / 2;

                i++;
               
            }
            Console.WriteLine(i);

[展开全文]

 double m = Convert.ToDouble(Console.ReadLine());
            int k = Convert.ToInt32(Console.ReadLine());
            if (k == 0)
            {
                int a = (int)m;
                Console.WriteLine(a);

            }
            else
            {
                int b = (int)(m * 100);
                if(b%10>=5)
                {
                    int c = (b / 10 + 1);
                    double d = (double)c;
                    Console.WriteLine(d/10);
                }
                else
                {
                    int c = (b / 10);
                    double d = (double)c;
                    Console.WriteLine(d/10);
                }
                
            }

[展开全文]

委托与函数的返回值需要一致
委托与函数的形参类型需要一致,命名可以不一致

delegate double WeiTuo(double S1, double S2);
        WeiTuo WT1;
        WT1 = CHEN;
        Console.WriteLine(WT1(2,4));
        WT1 = Chu;
        Console.WriteLine(WT1(16,4));

委托可以重复赋值,委托就是一个变量。

委托需要先赋值才可以使用,不赋值直接调用不可以使用、

委托返回值或形参与函数的返回值或形参不一致,不可以调用。

调用没有返回值且没有形参并且方法体只有“Console.WriteLine()”的语句直接 变量名();

[展开全文]

我为什么还要加什么和啊,我我是不知道a等于多少,还是不知道b等于多少?

不能直接等于那个值吗?

什么脑筋急转弯

int a=5;int b =10;

a=b;

b=5;

不行吗

[展开全文]

授课教师

问问题加入A计划,有专门负责答疑的老师哦!!!

课程特色

下载资料(1)
视频(117)
图文(3)