title: Write data into csv file
body: <p>Hi guys i'd like to write random double into a csv file ,for now am inserting string into the row, here is what i've done.How can alter my code in order to write doubles instead of string Many thanks in advance</p>
  
  <pre><code>public class CsvRow : List&lt;string&gt;
  {
      public string LineText { get; set; }
  }
  /// &lt;summary&gt;
  /// Class to write data to a CSV file
  /// &lt;/summary&gt;
  public class CsvFileWriter : StreamWriter
  {
      public CsvFileWriter(Stream stream)
          : base(stream)
      {
      }
  
      public CsvFileWriter(string filename)
          : base(filename)
      {
      }
      /// &lt;summary&gt;
      /// Writes a single row to a CSV file.
      /// &lt;/summary&gt;
      /// &lt;param name="row"&gt;The row to be written&lt;/param&gt;
      public void WriteRow(CsvRow row)
      {
          StringBuilder builder = new StringBuilder();
          bool firstColumn = true;
          foreach (string value in row)
          {
              // Add separator if this isn't the first value
              if (!firstColumn)
                  builder.Append(',');
              // Implement special handling for values that contain comma or quote
              // Enclose in quotes and double up any double quotes
              if (value.IndexOfAny(new char[] { '"', ',' }) != -1)
                  builder.AppendFormat("\"{0}\"", value.Replace("\"", "\"\""));
              else
                  builder.Append(value);
              firstColumn = false;
          }
          row.LineText = builder.ToString();
          WriteLine(row.LineText);
      }
  }      static void WriteTest()
      {
  
          // Write sample data to CSV file
          using (CsvFileWriter writer = new CsvFileWriter("D://WriteTest.csv"))   CsvRow rowCol = new CsvRow();
              for (int j = 0; j &lt; nbrCol; j++)
  
                 rowCol.Add("Col" +j);
  
              writer.WriteRow(rowCol);
          {
              for (int i = 0; i &lt; 100; i++)
              {
                  CsvRow row = new CsvRow();
                  for (int j = 0; j &lt; 5; j++)
                      row.Add(String.Format("Column{0}", j));
  
                  writer.WriteRow(row);
              }
          }
      }
  </code></pre>