Reverse word of full sentence

后端 未结 16 1905
眼角桃花
眼角桃花 2020-12-06 20:04

I want to print string in reverse format:

Input: My name is Archit Patel

Output: Patel Archit is name My.

I\'ve tied the

16条回答
  •  隐瞒了意图╮
    2020-12-06 20:39

    You could try:

    string[] words = "My name is Archit Patel".Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    IEnumerable reverseWords = words.Reverse();
    string reverseSentence = String.Join(" ", reverseWords);
    

提交回复
热议问题