zoukankan      html  css  js  c++  java
  • C#_基本类型

    1、C#中的值类型包括:简单类型、枚举类型和结构类型。

    2、C#中的引用类型包括:类(class)、接口(interface)、数组、委托(delegate)、object和string。

    3、调试时想要停留在控制台操作: Console.Readline();

        字符串强制转换成int型:Convert.ToInt32(Console.ReadLine());

       或者如下表示:

        string s = Console.ReadLine();
        int Grate = Convert.ToInt32(s);

    4、Console.Readline();    : 控制台接受输入的一个字符串。

        Console.Read();          :控制台接受输入的一个字符。

        a.GetLength(1)            :a数组第二维的长度。

        a.Length                     : a数组的总体长度,即元素总个数,与它的维数无关。

     1 using System;
     2 using System.Collections.Generic;
     3 using System.Linq;
     4 using System.Text;
     5 
     6 namespace MaxMin
     7 {
     8     class Program
     9     {
    10         static void Main(string[] args)
    11         {
    12             int max, min;
    13             int[] queue = new int[10];//{ 89, 76, 64, 3, 31, 62, 0, 91, 100, 21 };
    14             Console.WriteLine("请输入十个数到数组中:
    ");
    15             for (int i = 0; i < queue .Length; i++)
    16             {
    17                 queue[i] = Convert.ToInt32(Console.ReadLine());
    18             }
    19             for (int i = 0; i < 10; i++)
    20             {
    21                 Console.Write("{0,5}",queue[i]);
    22             }
    23             Console.WriteLine("
    ");
    24             max = min = queue[0];
    25             for (int i = 1; i < 10; i++)
    26             {
    27                 if (max < queue[i])
    28                 {
    29                     max = queue[i];
    30                 }
    31                 if (min > queue[i])
    32                 {
    33                     min = queue[i];
    34                 }
    35             }
    36             Console.WriteLine("最大数是{0},
    最小数是{1}", max, min);
    37         }
    38     }
    39 }
    View Code

     5、产生随机数:

                Random Rnd = new Random();
                int k;
                k = Rnd.Next(50);// 产生0到52之间的随机数
  • 相关阅读:
    javascript 中数字计算精度缺失问题
    javascript闭包
    MySQL数据库的创建
    原生项目使用 sass
    git工具命令
    如何将你的node服务放到线上服务器
    Cookie、Session、Token 的区别
    东北师大-构建之法-2020秋最终成绩(并非期末成绩)
    20201220-东北师范大学-助教-周总结-第14次
    东北师范大学-构建之法-20201207作业成绩
  • 原文地址:https://www.cnblogs.com/chensup/p/5818755.html
Copyright © 2011-2022 走看看