Write a C# Sharp program to reverse the case (upper->lower, lower->upper) of all the characters of given string
-
2021-05-30
- | ahmadghneem
- | م182
Write a C# Sharp program to reverse the case (upper->lower, lower->upper) of all the characters of given string.
Expected Output :
Original string: PHP After reversing the case of all characters of the said string: php Original string: JavaScript After reversing the case of all characters of the said string: jAVAsCRIPT Original string: Python 3.0 After reversing the case of all characters of the said string: pYTHON 3.0
الأجوبة
ابحث عن مسائل برمجة سي شارب | c# programming بالانجليزي
using System;
using System.Linq;
namespace exercises
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Original string: PHP");
Console.WriteLine("After reversing the case of all characters of the said string: " + test("PHP"));
Console.WriteLine("\nOriginal string: JavaScript");
Console.WriteLine("After reversing the case of all characters of the said string: " + test("JavaScript"));
Console.WriteLine("\nOriginal string: Python 3.0");
Console.WriteLine("After reversing the case of all characters of the said string: " + test("Python 3.0"));
}
public static string test(string text)
{
return string.Concat(text.Select(x => char.IsUpper(x) ? char.ToLower(x) : char.ToUpper(x)));
}
}
}
-
2021-05-30
- | ahmadghneem
- | إبلاغ عن إساءة
أسئلة مشابهة