stirng str="I am a man"; 变成 "man a am I"
不用sprit 怎么解决???
------解决方案--------------------------------------------------------
为什么不用呢
public static string ReverseWords(string sentence)
{
string[] words = sentence.Split(' ');
Array.Reverse(words);
return string.Join(" ", words);
}
------解决方案--------------------------------------------------------
- C# code
MatchCollection mat = Regex.Matches("I am a man", @"\w+\b"); List<string> mclist = new List<string>(); foreach (Match ma in mat) { mclist.Add(ma.Value); } mclist.Reverse(); foreach (string sm in mclist) { Console.Write(sm + " "); } /* man a am I */
------解决方案--------------------------------------------------------
是不用split吧