Manish Joisar Manish Joisar - 1 month ago 18
C# Question

CsvReader - Tab delimiter data

I am working with CsvReader from https://github.com/phatcher/CsvReader

Delimiter will be depend on type of data source, so my delimiter char stores in database.

It is working perfectly fine for Comma(,) and Pipe (|).

Now i got Tab separated values, and tab character is "\t" i.e. 2 character instead of 1 character which is expected by CsvReader.

So i changed data type of delimiter to Varchar(2), now while modifying it in C# throws error as "String must be exactly one character long"

Another option is to store Ascii value and convert to Char in C#.

Is there anything i can do with Escape character while converting string to char?

Answer

The string specified by the string literal "\t" is 1 character long. It just takes two characters (actually four including the quotes) to specify in a string literal.