How to write a value which contain comma to a CSV file in c#?

前端 未结 6 1369
时光取名叫无心
时光取名叫无心 2021-01-01 14:58

I am using a data table for storing data.

I am exporting the data from data table to CSV file.

Sometimes there may be values containing comma(,)

6条回答
  •  孤街浪徒
    2021-01-01 15:25

    Put Value in double quotes.

    string ValueToEscape = "a,b";
    
    "\"" + ValueToEscape + "\""
    

    CSV Output = a,b

提交回复
热议问题