I have a big log file with multiple lines separated by new line. Each line entry stores four values.
If I am reading the log file and want to store this information, what data type/object should I use?
Example:
source1 destination1 result time source2 destination1 result time sources3 destination2 result time
The values are not unique between lines and they can repeat.
Can I declare a struct for each line with {source, destination, result, time} values and store the struct object in a List<T> for the entire file?
Yes, you can take the approach of creating your own specific class and making a List of that class.
Depending on how large your file is, you could do better by using a DataTable to do this:
var dt = new DataTable();
dt.Columns.Add(new DataColumn("Source", typeof(string)));
dt.Columns.Add(new DataColumn("Destination", typeof(string)));
dt.Columns.Add(new DataColumn("Result", typeof(string)));
dt.Columns.Add(new DataColumn("Timestamp", typeof(DateTime)));
var dr = dt.NewRow();
dr["Source"] = "DATA";
dr["Destination"] = "DATA";
dr["Result"] = "DATA";
dr["Timestamp"] = DateTime.Now;
dt.Rows.Add(dr);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With