求.NET高手帮写一个简单程序
来源:百度知道 编辑:UC知道 时间:2024/06/22 03:53:44
private void button1_Click(object sender, System.EventArgs e)
{
Random r = new Random ();//随机数
int rndNum = r.Next(listBox1.Items.Count); //根据listbox1的内内容设置随机数的范围
MessageBox.Show(this.listBox1.Items[rndNum].ToString());//显示listBox1的内容
}
form1的代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Runtime.InteropServices;
using System.Net;
using System.IO;
using System.Text.RegularExpressions;
using System.Data.OleDb;
using System.Reflection;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button2_Click(object s