Writing a Header using CsvHelper? C#

You may be confused how CSVHelper works. This code handles the write aspect of your read in-write out loop: List<Employee> empList = new List<Employee>(); empList.Add(new Employee { FirstName = “Ziggy”, LastName = “Walters”, Wage = 132.50F }); empList.Add(new Employee { FirstName = “Zoey”, LastName = “Strand”, Wage = 76.50F }); using (StreamWriter sw = new … Read more

JSON string to CSV and CSV to JSON conversion in c#

I was able to solve it by DeserializeObject to a datatable using Json.net, so want to post my own answer but will not mark it as accepted, if anyone have better way to do this. To convert JSON string to DataTable public static DataTable jsonStringToTable(string jsonContent) { DataTable dt = JsonConvert.DeserializeObject<DataTable>(jsonContent); return dt; } To … Read more