I ran visual studio analysis on my code and i found that a large amount of time was spent concatenating strings. Is there a quicker way to concatenate?
string[] infoseperated = info.Split(' ');
for (int iii = totalremove; iii < infoseperated.Length; iii++)
{
newinfo += infoseperated[iii] + " ";
}
use
string.Joininstead:Your current approach generates a new string for every concatenation (since strings are immutable and you have to re-assign a new string), which is quite expensive.
For every concatenation all characters of the existing string have to be copied into the new string, so the cost of this operation grows with the number of characters in a string – it’s a Schlemiel the Painter’s algorithm
string.Joinuses aStringBuilderinternally which avoids this.