Int sum = 0;
ArrayList al = new ArrayList ();
Private void button#click (object sender, EventArgs e)
...{
String str = "";
FileStream s = new FileStream (@ "I: & # 92w.q.txt", FileMode. Open, FileAccess. Read );
StreamReader sr = new StreamReader (s, System. Text. Encoding. Default );
Do
...{
Str = sr. ReadLine ();
Sum ++;
Al. Add (str + "& #92; r & #92; n ");
} While (str! = Null | str = "");
String [] line = new string [al. Count + 1];
Al. CopyTo (line, 0 );
For (int I = 0; I <line. Length; I ++)
Str + = line [I];
TextBox1.Text = str;
Text = sum. ToString ();
}
C # create a dynamic array
Using System;
Using System. Collections;
Public class SC
...{
Static void Main ()
...{
ArrayList al = new ArrayList ();
Al. Add ("Hello ");
Al. Add ("");
Al. Add ("World ");
Al. Add ("! ");
String [] str = new string [al. Count];
Al. CopyTo (str, 0); // copy data from 0th locations
For (int I = 0; I <str. Length; I ++)
...{
Console. WriteLine (I. ToString () + str [I]);
}
}
} Another method is to create a dynamic array after reading and writing a file: