title: c# double to character array or alternative
body: <p>I have a program which stores a bunch of structs instances containing many members of type double. Every so often i dump these to a file, which I was doing using string builder e.g. :</p>
  
  <pre><code> StringBuilder builder = new StringBuilder(256);
  
   builder.AppendFormat("{0};{1};{2};", x.A.ToString(), x.B.ToString(), x.C.ToString()); 
  </code></pre>
  
  <p>where 'x' is an instance of my type, and A,B,C are members of X of type double. I call ToString() on each of these to avoid boxing. However, these calls to ToString still allocate lots of memory in the context of my application, and i'd like to reduce this. What i'm thinking is to have a character array, and write each member direct into that and then create one string from that character array and dump that to the file. Few questions:</p>
  
  <p>1) Does what i'm thinking of doing sound reasonable? Is there anything anyone knows of that would already achieve something similar?</p>
  
  <p>2) Is there already something built in to convert double to character array (which i guess would be up to some paramaterised precision?). Ideally want to pass in my array and some index and have it start writing to there. </p>
  
  <p>The reason i'm trying to do this is to reduce big spikes in memory when my app is running as I run many instances and often find myself limited by memory. </p>
  
  <p>Cheers
   A  </p>