Dear Sir:
I am new at C# and I have a question as following. My original code is:
using System.IO;
namespace WindowsTest
{
public partial class Form1 : Form
{
public TextBox TextBoxlist(int index)
{
TextBox [] textlist={textBox1,textBox2};
return textlist[index];
}
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
ReadFile();
}
private void button1_Click(object sender, EventArgs e)
{
CreateFile();
}
public void CreateFile()
{
try
{
StreamWriter writer = new StreamWriter("Savefile.txt", false);
for (int i = 0; i < 2; i++)
{
writer.WriteLine(TextBoxlist(i).Text);
}
writer.Close();
MessageBox.Show("Saved Successfully");
}
catch
{
MessageBox.Show("Saved Faild");
}
}
public void ReadFile()
{
try
{
StreamReader reader = new StreamReader("Savefile.txt"); // using System.IO;
string readerStr = reader.ReadLine();
int inde = 0;
while (inde < 2)
{
TextBoxlist(inde).Text = readerStr;
readerStr = reader.ReadLine();
inde++;
}
reader.Close();
}
catch
{
}
}
}
}
But now I had many TextBox ( more then 100), could you plese teach how to write a simple code insteal
TextBox [] textlist={textBox1,textBox2,textBox3,textBox4,textBox5 ............};
Thank you.











