将一句话里的单词进行倒置,标点符号不倒换。比如将“I come from Shanghai.”倒换后变为“Shanghai. from come I”

string str = "I come from Shanghai.";
//根据空格切割
string[] strS = str.Split(' ');

string tempStr = "";
for (int i = strS.Length - 1; i >= 0; i--)
{
    tempStr = tempStr + strS[i] + " ";
}

//去掉首尾空格
tempStr = tempStr.Trim();

方法有多种。走过路过的朋友,可以发表想法,说说思路。

原文地址:https://www.cnblogs.com/gilbert/p/5358699.html