Vinay G
Vinay G

Reputation: 367

Writing double quote into csv is resulting in three double quotes

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

Upvotes: 2

Views: 583

Answers (1)

Cid
Cid

Reputation: 15257

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"""

Upvotes: 3

Related Questions