-3

Need assistant :) Trying to create a csv/txt file I need some of the text to have " before and after the text How can i do that, i have tried several things with no luck

This is my code

                    using (StreamWriter writer = new StreamWriter(@"c:\temp\testfile.txt"))
                    // Using Name and Phone as example columns.
                    writer.WriteLine("number,surname");

I have a database where i get data with format like the picture I need to create a csv file with that data, with header and data It is about 20000 rows enter image description here And data under them with same format

Cheers

Ace2874
  • 25
  • 7

1 Answers1

0

If i understood what you're asking correctly, you could try it like that:

string line = "\"number\",\"surname\"";
writer.WriteLine(line);

Give it a go! :) Oh and don't forget to mark as answered if it solves your problem.

  • Thanks and if i want to user strings/var like this number = rd[3].tostring(); – Ace2874 Aug 24 '23 at 19:12
  • Sorry, i don't think i understood what you're asking. If it's a int, you can't have rd[3] as a value, [] this would be for a array. Could you be more specific? – Pedro Perondini Aug 24 '23 at 19:37