
10 Dec
2006
10 Dec
'06
8:58 a.m.
On 10/12/2006, at 10:50 PM, Andrew Savige wrote:
A popular C# approach goes something like:
private static string reverseWords(string str) { string[] words = Array.FindAll<string>(str.Split( new char[] {' ','\t'}), delegate(string s) { return !String.IsNullOrEmpty(s); }); int i = words.Length - 1; if (i < 0) return String.Empty; StringBuilder sb = new StringBuilder(words[i]); while (--i >= 0) sb.Append(' ').Append(words[i]); return sb.ToString(); }
Yikes! There ought to be a law against public displays of C# which are not accompanied by health warnings. :-) Cheers, Bernie.