不好意思。。出了点小错!这是修改后的!
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace KinroStudy
{
public partial class Stochastic : Form
{
public Stochastic()
{
InitializeComponent();
}
#region & 成生随机数
public static string str_char(int Length, bool Sleep)
{
if (Sleep)
{
System.Threading.Thread.Sleep(3);//阻止线程指定时间
}
#region & 成生数组值
int Setnum = 65;//A的Ascii码值是65
char Getletter;//获取Ascii对应的字母
char[] Pattern = new char[26];
for (int i = 0; i < 26; i++)
{
Getletter = (char)Setnum;
Pattern[i] = Getletter;
Setnum = Setnum + 1;
}
#endregion
string Result = "";
int GetLength = Pattern.Length;
System.Random myrandom = new Random(~unchecked((int)DateTime.Now.Ticks));
for (int j = 0; j < Length; j++)
{
int Rnd = myrandom.Next(0, GetLength);
Result += Pattern[Rnd];
}
return Result;