假设以下是字符串 -
'Welcome
翻转字符串后,单词应该像 − 这样可见。
'emocleW
使用reverse()方法并尝试以下代码来反转字符串中的单词 -
示例
'using System;
using System.Linq;
class Demo {
static void Main() {
string str = "Welcome";
// reverse the string
string res = string.Join(" ", str.Split(' ').Select(s => new String(s.Reverse().ToArray())));
Console.WriteLine(res);
}
}