How to embed quotation marks in output file C

rwheeler23
rwheeler23 used Ask the Experts™
on
I am using this to write data to a comma delimited text  file.
tw.WriteLine("{0,1},{1,1},{2,1},{3,1},{4,1},{5,1},{6,1},{7,1},{8,1},{9,1},{10,1}", dr["Arrest_ID"],dr["Incident"],dr["Arrest_Date"],dr["Arrest_Time"],dr["Age"],dr["Sex"],dr["Race"],dr["Ethnic"],dr["Crime_Location"],dr["ESRI_LOCATION"],dr["Law"]);

Now they are requesting that I enclose the text fields in quotation marks. Is it as simple as "{0,1}"?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Co-Founder and Chief Architect
Top Expert 2016
Commented:
More or less, you just need to either escape the quotes with \" or do a string literal.

But not 100% sure what class tw (custom or TextWriter?)
NorieAnalyst Assistant
Commented:
Try using \".

Not 100% sure which fields are text so the below adds " around all of them.:)
w.WriteLine("\"{0,1}\",\"{1,1}\",\"{2,1}\",\"{3,1}\",\"{4,1}\",\"{5,1}\",{6,1}\",\"{7,1}\",\"{8,1}\",\"{9,1}\",\"{10,1}\"", dr["Arrest_ID"],dr["Incident"],dr["Arrest_Date"],dr["Arrest_Time"],dr["Age"],dr["Sex"],dr["Race"],dr["Ethnic"],dr["Crime_Location"],dr["ESRI_LOCATION"],dr["Law"]);

Open in new window

rwheeler23President

Author

Commented:
Thanks folks. That did the trick.
rwheeler23President

Author

Commented:
Thnaks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial