I have a class like this
class Car
{
public string carname{get;set;}
public int id{get;set};
public string mdate{get;set;}
}
I have a List of Car and I need to write each of the car's properties as a delimited string into a file
List<Car> cars =new List<Car>();
Right now am achieving it using loop as below
foreach(car c in cars)
{
string s=c.carname + "," + c.id + "," + c.mdate;
f.writeline(s);
}
But if the number of properties are huge its difficult to do the same. So is there is any easy way to achieve the above. Something like linq or any other way..
Also is there is any way of specifying the order of columns in CSV