string[] arr = Console.ReadLine().Split(' '); string result = string.Empty; for (int i = arr.Count() - 1; i >= 0; i--) { result += arr[i] + " "; } Console.WriteLine("反转后的英文句子是:" + result); Console.ReadKey();
字母全部反转
public char[] ceshi(string mess) { char[] a = mess.ToCharArray(); Array.Reverse(a); return a; }
Class2 ceshi2 = new Class2(); string ceshi3=string.Empty; foreach(char i in ceshi2.ceshi("abc")){ ceshi3+=i.ToString(); } Console.WriteLine(ceshi3)