zoukankan      html  css  js  c++  java
  • c#数组用法

    随机数:

    string[]  str = new string[4]{"a","b","c","d"}

    Readom r = new Readom();

    int a = r.Next(0,str.length);     获得一个随机数,从零开始,返回int a

    console.writeLine(str[a])   a 就是随机数

    随机输出一个随机数,[]里放索引,int 类型是从0到最长度减一。

    制作抽奖程序:

    for(int i =1;i<10;i++)

    {

    console.writeLine(i);

    System.Threading.Thread.Sleep(500);     放毫秒,输出完,停一下。

    console.clear();     输出完了,清除。

    }

    console.writeLine("内容");     想让谁中奖,可以提前写上

    console.readLine();

    定义一个int型数组,长度是3,里面放1,5,7。使1和7位置换换

    int  i  = new int[]{1,5,7};

    int a = i[0];

    i[0] = i[i.length-1];

    i[i.length-1] = a;

    for(int c = 0;c<i.length;c++)

    {

    console.WriteLine(i[c]);

    }

    console.ReadLine();

  • 相关阅读:
    Redis其他知识
    Mybatis的sql语句操作
    Redis
    mybatis插件原理
    mybatis工作原理
    Mybatis逆向工程
    mybatis缓存机制
    Mybatis查询
    zabbix api添加主机
    jenkins + bitbucket 实现 pr自动构建及build状态通知
  • 原文地址:https://www.cnblogs.com/yunpeng521/p/6985439.html
Copyright © 2011-2022 走看看