Search code examples
c#servicestackservicestack-text

convert object to CSV string without header Servicestack CSVSerializer


I'm using Servicestack.text CSV serializer to serialize an object into CSV format. Here is the way Im trying

CsvSerializer.SerializeToString(MyObject)

But it converts into CSV including the headers like this

ID,Name, Age\r\n13,Alex,45

But I dont need those headers. Is there is any way to exclude the header


Solution

  • You can omit headers for being written per Type with:

    CsvConfig<MyType>.OmitHeaders = true;