C#
public static string Reverse(string sentence)
{
string[] words = sentence.Split(' ');
Array.Reverse(words);
return string.Join(" ", words);
}
VB.NET
Public Shared Function Reverse(sentence As String) As String
Dim words As String() = sentence.Split(" "C)
Array.Reverse(words)
Return String.Join(" ", words)
End Function
Input: Hello! World
Output: World Hello!
public static string Reverse(string sentence)
{
string[] words = sentence.Split(' ');
Array.Reverse(words);
return string.Join(" ", words);
}
VB.NET
Public Shared Function Reverse(sentence As String) As String
Dim words As String() = sentence.Split(" "C)
Array.Reverse(words)
Return String.Join(" ", words)
End Function
Input: Hello! World
Output: World Hello!
This comment has been removed by a blog administrator.
ReplyDelete