高效字符串逆转
1 public static string Reverse(this String str) 2 { 3 char[] array = str.ToCharArray(); 4 int n = array.Length - 1; 5 for (int i = (n - 1) >> 1; i >= 0; i--) 6 { 7 int j = n - i; 8 char temp = array[i]; 9 array[i] = array[j]; 10 array[j] = temp; 11 } 12 return new string(array); 13 }
不会飞的鱼~~~~梦想总要有的,万一实现了呢!
尊重他人劳动成功。转载请注明出处! http://www.cnblogs.com/flyfishing/
尊重他人劳动成功。转载请注明出处! http://www.cnblogs.com/flyfishing/