5
String Handling, continued
lStringBuilder – preallocates memory and appends string segments into that memory, much faster than repeated use of string=string+newString
§/* build string representing contents of a string[] array */
§private string ArrayToString(string[] array)
§ {
§ StringBuilder Output=new StringBuilder(1000);
§ int i;
§ if (array.Length==0) return "";
§ for (i=0;i<array.Length;i++)
§ Output.Append("\",\""+array[i].ToString());
§ return "("+Output.ToString().Substring(2)+"\")";
§ }
lFormatting values into strings:
Ø String.Format("Format {0,10:E} and {0,8:F} of pi and e:", System.Math.PI,
Ø     System.Math.E);
l