Write tab separated csv file in c#
<p>I am currently developing an application in C# where I need to write a tab separated CSV file from the data that it retrieves from a MySQL Database. The database retrieval works fine. </p>

<p>The problem that I am having is writing the file. Between each variable that I am writing I am using the \t which I thought put a tab into the csv, therefore when opening in excel each variable will be in its own cell. </p>

<p>However for some reason it is not doing this it just writes the whole line as one long string. Below is an example of the code that I am code that I have written:</p>

<pre><code>while (reader.Read())
{
    int bankID = reader.GetInt16("ban_bankID");
    int userID = reader.GetInt16("ban_userID");
    string bankUsername = reader.GetString("ban_username");
    string accountName = reader.GetString("ban_accountName");
    string accountType = reader.GetString("ban_accountType");
    decimal overdraft = reader.GetDecimal("ban_overdraft");
    char defaultAccount = reader.GetChar("ban_defaultAccount");

    string line = bankID + "\t" + userID + "\t" + bankUsername + "\t" + accountName + "\t"
              + accountType + "\t" + overdraft + "\t" + defaultAccount + "\n";

    tw.WriteLine(line);
</code></pre>

<p>Thanks for your help with this problem.</p>
