cs:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace GDI_绘图
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
string code;
Random r = new Random();
//加载事件
private void Form3_Load(object sender, EventArgs e)
{
setCode(4);//验证码四个长度
}
private void setCode(int length)
{
code = "";
for (int i = 0; i < length; i++)
{
int type = r.Next(0,2);//存在两次
if (type==0)
{
code += r.Next(0, 9);