The code used for comparison
The main is the comparison of the + and the built-in string merging methods directly using string
Random rand=new random (); Byte[] A = new byte[10000]; for (int i = 0; i < a.length; ++i) a[i] = (byte) rand. Next (n); DateTime now1 = DateTime.Now; string S1 = ""; for (int i = 0; i < a.length; ++i) S1 + = Convert.ToString (A[i], +) + ""; DateTime end1 = DateTime.Now; DateTime now2 = DateTime.Now; List<string> s2=new list<string> (); for (int i = 0; i < a.length; ++i) S2. ADD (Convert.ToString (a[i], +)); String s3 = String. Join ("", S2. ToArray ()); DateTime end2 = DateTime.Now; MessageBox.Show ((END1-NOW1). Totalmilliseconds.tostring () + ":" + "\ n" + (END2-NOW2). Totalmilliseconds.tostring () + ":" + "\ n");
Print results
55.00311.0001
The result: The built-in method is a victory over the string addition, the more merges the more obvious.
. NET makes string addition a waste of CPU