c#的随机函数怎样用! System.Random rnd = new System.Random();Response.Write(rnd.Next(10000).ToString());返回10000以内的非负数 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用系统时间生成随机数using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.Data;namespace WindowsApplication1{ /// <summary> /// Form1 的摘要说明。 /// </summary> public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; private System.Windows.Forms.TextBox textBox2; private System.Windows.Forms.Label label3; private System.Windows.Forms.TextBox textBox3; private System.Windows.Forms.Button button1; /// <summary> /// 必需的设计器变量。 /// </summary> private System.ComponentModel.Container components = null; public Form1() { // // Windows 窗体设计器支持所必需的 // InitializeComponent(); // // TODO: 在 InitializeComponent 调用后添加任何构造函数代码 // } /// <summary> /// 清理所有正在使用的资源。 /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.textBox1 = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.textBox2 = new System.Windows.Forms.TextBox(); this.label3 = new System.Windows.Forms.Label(); this.textBox3 = new System.Windows.Forms.TextBox(); this.button1 = new System.Windows.Forms.Button(); this.SuspendLayout(); // // textBox1 // this.textBox1.Location = new System.Drawing.Point(88, 16); this.textBox1.Name = "textBox1"; this.textBox1.TabIndex = 0; this.textBox1.Text = ""; // // label1 // this.label1.Location = new System.Drawing.Point(16, 16); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(48, 23); this.label1.TabIndex = 1; this.label1.Text = "随机数"; // // label2 // this.label2.Location = new System.Drawing.Point(16, 48); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(72, 23); this.label2.TabIndex = 2; this.label2.Text = "系统时间:"; // // textBox2 // this.textBox2.Location = new System.Drawing.Point(88, 48); this.textBox2.Name = "textBox2"; this.textBox2.TabIndex = 3; this.textBox2.Text = ""; // // label3 // this.label3.Location = new System.Drawing.Point(16, 80); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(56, 23); this.label3.TabIndex = 4; this.label3.Text = "转换量:"; // // textBox3 // this.textBox3.Location = new System.Drawing.Point(88, 80); this.textBox3.Name = "textBox3"; this.textBox3.TabIndex = 5; this.textBox3.Text = ""; // // button1 // this.button1.Location = new System.Drawing.Point(56, 120); this.button1.Name = "button1"; this.button1.TabIndex = 6; this.button1.Text = "生成"; this.button1.Click += new System.EventHandler(this.button1_Click); // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.ClientSize = new System.Drawing.Size(208, 157); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.button1, this.textBox3, this.label3, this.textBox2, this.label2, this.label1, this.textBox1}); this.Name = "Form1"; this.Text = "Form1"; this.Load += new System.EventHandler(this.Form1_Load); this.ResumeLayout(false); } #endregion /// <summary> /// 应用程序的主入口点。 /// </summary> [STAThread] static void Main() { Application.Run(new Form1()); } private void Form1_Load(object sender, System.EventArgs e) { } private void button1_Click(object sender, System.EventArgs e) { System.Random rnd = new System.Random(); DateTime dt=DateTime.Now; textBox2.Text=dt.ToString(); int rndpar=(int)dt.Ticks; textBox3.Text=rndpar.ToString(); textBox1.Text=rnd.Next(rndpar).ToString(); } }} IReaper还能不能用了? 点击gridview排序的问题 在win2000下,label背景问题 坐等,急!!!! DiertoryInfo在那个命名空间下 在线等,马上结帖,C#有什么好的画曲线图控件? 求助如何连接数据库以及对数据库操作 如何按类中的成员对类数组排序? c#中的标签 怎样在.Net中得MDI中改变MDI的背景色? 都说C#可以做ActiveX的控件,那里生成项目啊? 请问有谁知道vs.net里面的工具箱的功能是怎么实现的,也就是怎么实现隐藏菜单!!!
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;namespace WindowsApplication1
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.Button button1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null; public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.textBox3 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(88, 16);
this.textBox1.Name = "textBox1";
this.textBox1.TabIndex = 0;
this.textBox1.Text = "";
//
// label1
//
this.label1.Location = new System.Drawing.Point(16, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(48, 23);
this.label1.TabIndex = 1;
this.label1.Text = "随机数";
//
// label2
//
this.label2.Location = new System.Drawing.Point(16, 48);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(72, 23);
this.label2.TabIndex = 2;
this.label2.Text = "系统时间:";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(88, 48);
this.textBox2.Name = "textBox2";
this.textBox2.TabIndex = 3;
this.textBox2.Text = "";
//
// label3
//
this.label3.Location = new System.Drawing.Point(16, 80);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(56, 23);
this.label3.TabIndex = 4;
this.label3.Text = "转换量:";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(88, 80);
this.textBox3.Name = "textBox3";
this.textBox3.TabIndex = 5;
this.textBox3.Text = "";
//
// button1
//
this.button1.Location = new System.Drawing.Point(56, 120);
this.button1.Name = "button1";
this.button1.TabIndex = 6;
this.button1.Text = "生成";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(208, 157);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.button1,
this.textBox3,
this.label3,
this.textBox2,
this.label2,
this.label1,
this.textBox1});
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false); }
#endregion /// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
} private void Form1_Load(object sender, System.EventArgs e)
{
} private void button1_Click(object sender, System.EventArgs e)
{
System.Random rnd = new System.Random();
DateTime dt=DateTime.Now;
textBox2.Text=dt.ToString();
int rndpar=(int)dt.Ticks;
textBox3.Text=rndpar.ToString();
textBox1.Text=rnd.Next(rndpar).ToString();
}
}
}