Implement a function to reverse the order of words in a given sentence.
Implement a function to reverse the order of words in a given sentence.
Student
I am Utpal Vishwas from Uttar Pradesh. Have completed my B. Tech. course from MNNIT campus Prayagraj in 2022. I have good knowledge of computer networking.
Sure, here is a C# function to reverse the order of words in a given sentence:
C#
This function first splits the sentence into words using the Split() method. It then reverses the order of the words using the Reverse() method. Finally, it joins the words back together into a sentence using the Join() method.
Here is an example of how to use the ReverseWords() function:
C#
This code will print the following output:
Code snippet