char[] s = new char[]{'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','v','w','x','y','z','A','B','C','D','E','F','G'
,'H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W'
,'X','Y','Z'};
string num="";
Random r = new Random();
for(int i = 0; i < 5; i++)
{
num += s[r.Next(0,s.Length)].ToString();
}
return num;
这是个随机的验证码函数,你自己修改下就可以了
,'b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q'
,'r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G'
,'H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W'
,'X','Y','Z'};
string num="";
Random r = new Random();
for(int i = 0; i < 5; i++)
{
num += s[r.Next(0,s.Length)].ToString();
}
return num;
这是个随机的验证码函数,你自己修改下就可以了
解决方案 »
- WPF中如果在xaml文件和相应的xaml.cs文件中分别定义了两个不同Grid,这两个是什么关系呢?
- 请教一个计算网页深度的办法!
- 线程问题
- 菜鸟请求帮助~~关于winform中问题
- 哪种源代码管理器比较安全?VSS安全性太差了。
- 缺少using指令 这是什么原因?
- 请问如何在.net里面调用oracle的函数?是不是跟调用sp一样。我指的函数就是类似用function开头的。而且有返回值的函数怎么调用返回,谢谢
- 在执行拖放操作时,如何判断一个文件该放在树的哪个分支,即tvw_DragDrop时如何获取鼠标停留的位置,谢
- 如何把一个变量的字符串型转成日期型
- 卖血求救,各位大吓帮帮忙啊!关于网站服务器和C#客户端的通讯
- label与timer结合实现的问题
- 高手帮忙,请问怎么将一些文本转化为二进制?
Form1.cs(123): 由于“WindowsApplication9.Form1.button1_Click(object, System.EventArgs)”返回 void,返回关键字后面不得有对象表达式
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;namespace WindowsApplication4
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
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 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(40, 40);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(200, 24);
this.label1.TabIndex = 0;
this.label1.Text = "label1";
//
// button1
//
this.button1.Location = new System.Drawing.Point(96, 152);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(96, 32);
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false); }
#endregion /// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
public static string GetNum()
{
string[] s = new string[]{"0","1","2","3","4","5","6","7","8" ,"9","10"};
string num="";
Random r = new Random();
num += s[r.Next(0,s.Length)].ToString();
return num;
} private void button1_Click(object sender, System.EventArgs e)
{
label1.Text=Form1.GetNum();
} }
}
{
label1.Text =Num.ToString ();
}循环结束自然是10啦!要用随机变量
{
label1.Text =Num.ToString ();
}
每1次循环 label1.Text 都得到一个值,循环结束了,最后得到的是10,结果当然是10咯
private void button1_Click(object sender, System.EventArgs e)
{
int Num=0;
string s=""
for(Num=1;Num<=10;Num++)
{
s=s+Num.ToString ();
}
label1.Text=s
}
你的代码是把Num 的值全部显示出来,而不是一个一个的显示我想实现的是点击一次出现一个数值 :)
请到这里领分:
http://community.csdn.net/Expert/topic/3780/3780289.xml?temp=.32745