Yes that is exactly what I would do. If you don't have LINQ you can use generic List with a custom class of your own.
public class LogEntry
{
private String _source = String.Empty;
private String _destination = String.Empty;
private String _result = String.Empty;
private String _time = String.Empty;
public String Source
{
get { return _source; }
set { _source = value; }
}
public String Destination
{
get { return _source; }
set { _source = value; }
}
public String Result
{
get { return _source; }
set { _source = value; }
}
public String Time
{
get { return _source; }
set { _source = value; }
}
public LogEntry()
{
}
public LogEntry( String source, String destination, String result, String time )
{
_source = source;
_destination = destination;
_result = result;
_time = time;
}
public LogEntry( String[] args )
{
_source = args[0];
_destination = args[1];
_result = args[2];
_time = args[3];
}
}
You can then use a list like so:
List<LogEntry> _logEntries = new List<LogEntry>();
I would read the each line from the file into a String and create a new LogEntry class passing in the result from a String.Split method call. The code below is strictly psuedo code.
char[] splitter = new char[1];
splitter[0] = ' ';
while( readLines into String )
{
_logEntries.Add( new LogEntry( String.Split( splitter ) ) );
}
This solution is extremely brittle and any change in the log file format will horribly break the code but it will work. Also your breaking on white space so you better make sure that's what you really want to break on.