How do I insert tabs into strings for a C# console application?

Thomas picture Thomas · Jan 6, 2013 · Viewed 43.5k times · Source

This console application will write .txt files to disc.

User wants to import these .txt files into Excel such that they are formatted correctly, so I plan to use tabs.

I keep getting this nonsense "Some string /t some other string /t/t some other string". There is no Environment.Tab like there is Environment.NewLine.

How do I get the tabs and not /t into my strings?

I'm sure there's a way and it'll probably be so obvious that I'll have to call myself faint all day on response.

(I'm open to other solutions as well. I might have to use | or some other delimiter/character.)

Answer

Dan Puzey picture Dan Puzey · Jan 6, 2013

Tabs in strings are typically written \t, not /t. Are you escaping your string correctly?