• 字符串的反转以及随机数生成


    经常有面试题考到字符串的反转和随机数生成。今天在这里记录一笔。

    字符串的反转是有专门的方法的,.net里面有Reverse()方法就可以反转。

      string name = "明天会更好";
            var collection = Enumerable.Reverse(name);
            foreach (var element in collection)
            {
                Response.Write(element);
            }

    这样输出的结果就是。好更会天明

    说一下不重复的随机数,其实就是生成随机数与已经生成的随机数作比较,如果重复就继续生成。

     public List<int> getRandom()
        {
            List<int> result = new List<int>(6);
            Random rand = new Random();
            int temp = 0;
            while (result.Count < 6)
            {
                temp = rand.Next(1, 34);
                if (!result.Contains(temp))
                    result.Add(temp);
            }
            return result;
        }
  • 相关阅读:
    MQTT
    群晖搭建webssh
    OSI 协议
    centos7 yum安装ffmpeg,以及ffmpeg的简单用法
    centos7 RTMP直播服务器搭建
    elasticsearch
    H5的storage
    bootstrap 列表組
    eclipse的debug模式下启动不了tomcat
    bootstrap collapse
  • 原文地址:https://www.cnblogs.com/zlzly/p/2848633.html
Copyright © 2020-2023  润新知