How often did you have to read data separated by, for example, a comma (CSV format) from a file, process it and do something with it in the future?10248 | VINET | 04071996 | 32.38
10249 | TOMSP | 05071996 | 11.61
10250 | HANAR | 08071996 | 65.83
10251 | VICTE | 08071996 | 41.34
...............
[DelimitedRecord ( "|" )] // Define the delimiter
public class Orders
{
public int OrderID;
public string CustomerID;
[FieldConverter (ConverterKind.Date, "ddMMyyyy" )]
public DateTime OrderDate;
public decimal Freight;
} * This source code was highlighted with Source Code Highlighter .
FileHelperAsyncEngine engine = new FileHelperAsyncEngine ( typeof (Orders));
engine.BeginReadFile ( "TestIn.txt" );
// The engine is IEnumerable
foreach (orders ord in engine)
{
// your code here
Console .WriteLine (ord.CustomerID);
}
engine.Close ();
* This source code was highlighted with Source Code Highlighter .
Source: https://habr.com/ru/post/25885/
All Articles