如何接收这个随机数?
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _213213 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.TextBox1.Text = "接收产生的随机数 ";
}
public string RndNum(int VcodeNum)
{
string Vchar = "0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,W,X,Y,Z ";
string[] VcArray = Vchar.Split( ', ');
string VNum = " ";//由于字符串很短,就不用StringBuilder了
int temp = -1;//记录上次随机数值,尽量避免生产几个一样的随机数
//采用一个简单的算法以保证生成随机数的不同
Random rand = new Random();
for (int i = 1; i < VcodeNum + 1; i++)
{
if (temp != -1)
{
rand = new Random(i * temp * unchecked((int)DateTime.Now.Ticks));
}
int t = rand.Next(35);
if (temp != -1 && temp == t)
{
return RndNum(VcodeNum);
}
temp = t;
VNum += VcArray[t];
}
return VNum;
}
}
运行程序产生的随机数,用一个textbox来接收.
产生随机数的程序有问题吗,如何接收到这个随机数呢?
----