ArrayList arString = new ArrayList();
ArrayList arInt = new ArrayList();
using (StreamReader sr = new StreamReader("input.txt"))
{
. . . char[] delim = new char[] { ' ' }; // space char delimiter
. . . String line;
. . . while ((line = sr.ReadLine()) != null)
. . . {
. . . . . . string [] split = line.Split(delim);
. . . . . . for ( int i = 0 ; i < split.Length ; i++ )
. . . . . . {
. . . . . . . . . try
. . . . . . . . . {
. . . . . . . . . . . . . arInt.Add( Convert.ToInt32( split [ i ] ) );
. . . . . . . . . }
. . . . . . . . . catch( Exception ex )
. . . . . . . . . {
. . . . . . . . . . . . arString.Add( split [ i ] );
. . . . . . . . . }
. . . . . . }
. . . }
}
Редактирано от шeф нa Coди Дeвня на 23.01.04 19:28.