求会C#的朋友!

来源:百度知道 编辑:UC知道 时间:2024/09/22 20:33:12
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace DeviceApplication21
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
String str1 = this.textBox1.Text;
String str2 = this.textBox1.Text;
String str3 = this.textBox1.Text;
String[] arr = new string[3];
arr[0] = str1;
arr[1] = str2;
arr[2] = str3;
arr.SetValue(str1,0);
arr.SetValue(str2,1);
arr.SetValue(str3,2);
Form2 f2 = new Form2(arr);
f2.ShowDialog();

}
}

代码正常,我把你的代码放到我新建的测试项目可以正常显示,可能你的IDE有问题,或其他什么问题,你代码正确

Form可能不支持重构
this.label1.Text = arr[0].ToString();
this.label2.Text = arr[1].ToString();
this.label3.Text = arr[2].ToString();