Writing double quote into csv is resulting in three double quotes

Viewed 72

Iam using dapper to read some values from db and write it into a csv, for a particular column I want to write the column with double quoted string

$"\"{x.Notes}\"", I have tried this but when I write it into the csv it is resulting in three double quotes

1 Answers

This is a normal behaviour.

When a string contains specials characters, such as separators, newlines or double quotes, that string must be wrapped into double quotes. The double quotes are then doubled.

Some examples :

foo "Hello world" bar becomes "foo ""Hello world"" bar"

foo "bar" becomes "foo ""bar"""

"foo" becomes """foo"""

Related