C#: Reverse a given string in uppercase
Write a C# Sharp program to reverse a given string in uppercase.
Sample Solution:-
C# Sharp Code:
using System;
using System.Linq;
namespace exercises
{
class Program
{
static void Main(string[] args)
{
// Display original string and its uppercase transformation
Console.WriteLine("Original string: php");
Console.WriteLine("Said string in uppercase: " + test("php"));
// Repeat the same steps for different strings
Console.WriteLine("Original string: java");
Console.WriteLine("Said string in uppercase: " + test("java"));
Console.WriteLine("Original string: abcd");
Console.WriteLine("Said string in uppercase: " + test("abcd"));
}
// Method to reverse a string and convert it to uppercase
public static string test(string text)
{
// Reverse the characters of the input string and convert it to uppercase
return new string(text.ToCharArray().Reverse().ToArray()).ToUpper();
}
}
}
Sample Output:
Original string: php Said string in uppercase: PHP Original string: java Said string in uppercase: AVAJ Original string: abcd Said string in uppercase: DCBA
Flowchart :
C# Sharp Code Editor:
Improve this sample solution and post your code through Disqus
Previous: Write a C# Sharp program to get the longest Palindromic substring from a given string.
Next: Write a C# Sharp program to remove duplicate characters from a given string.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics