一个长度为1000的字符串,由a-j10个随机字母组成,该怎么获得该字符串?

解决方案 »

  1.   

    随机一千次然后往StringBuilder里累加,最后再ToString
      

  2.   

    string str = "";
    Random rd = new Random();
    for (int i = 0; i < 1000; i++)
    {
        str += "abcdefghij".Substring(rd.Next(10), 1);
    }
    Console.Write(str);
      

  3.   


     /// <summary>
            /// 提取
            ///  </summary>
            public static string TiQu_ZiMu(string Str)
            {
                Regex i;
                i = new Regex(@"[a-j]{1000}");
                Match m;
                m = i.Match(Str);
                return m.ToString();
            }
      

  4.   

    using System;class Program

      static void Main() 
      { 
        Byte[] b = new Byte[1000];
        new Random().NextBytes(b);
        for (int i = 0; i < b.Length; i++)
          b[i] = (byte)(b[i] % 10 + 'a');
        char[] c = new char[b.Length];
        Array.Copy(b, c, b.Length);
        string s = new string(c);
        Console.WriteLine(s);
      }
    }