Which is more preferable? Performance or Memory while spliting a string in C#? : <p>I would like to ask that which case of the two below is more preferable than the other considering garbage collection, memory and cpu usage in C#.</p>

<pre><code>a = data.Split('|')[0];
b = data.Split('|')[1];
c = data.Split('|')[2];
d = data.Split('|')[3];
e = data.Split('|')[4]; 
</code></pre>

<p>or</p>

<pre><code>string[] splitedData = data.Split('|');

a= splitedData[0];
b = splitedData[1];
c = splitedData[2];
d = splitedData[3];
e = splitedData[4];
</code></pre>

<p>I would prefer the second one since I think holding the splited data array reference and accessing from using that reference is less cpu-intensive and uses less memory access.</p>

<p>The first one uses more cpu and creates an array at each time (filling and accessing the array requires also more memory operation) in order to get the data accordingly.</p>

<p>I am asking this question because I saw in a game project created by Chupamobile that the first one was used.</p>

<p>Thanks in advance.</p>
