Не получается передать данные из формы 2 в форм 1 - C#
Формулировка задачи:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace сумма
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int n, n1, i;
int[] A = new int[10];
private void button1_Click(object sender, EventArgs e)
{
n1 = Convert.ToInt32(textBox1.Text);
if (n1 > 0 & n1 < 11)
{
n = n1;
}
if (n > 0)
{
for ( i = 1; i<=n; i++ )
{
Form2 f = new Form2(); //в форме 2 должна вводится A[i]
f.ShowDialog();
string s = (A[i] + " ");
MessageBox.Show(s);
}
}
}
}
}using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace сумма
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
int n;
public void button1_Click(object sender, EventArgs e)
{
n = Convert.ToInt32(textBox1.Text); //что здесь надо написать? не могу не как понять.
}
}
}Решение задачи: «Не получается передать данные из формы 2 в форм 1»
textual
Листинг программы
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
public int NewNumber;
private void button1_Click(object sender, EventArgs e)
{
NewNumber = Convert.ToInt32(textBox1.Text);
this.DialogResult = DialogResult.OK;
}
}
}