Write a C# Sharp program to convert the letters of a given string (same case-upper/lower) into alphabetical order


Write a C# Sharp program to convert the letters of a given string (same case-upper/lower) into alphabetical order

Sample Output:

Original string: PHP
Convert the letters of the said string into alphabetical order: HPP
Original string: javascript
Convert the letters of the said string into alphabetical order: aacijprstv
Original string: python
Convert the letters of the said string into alphabetical order: hnopty

الأجوبة

ابحث عن مسائل برمجة سي شارب | c# programming بالانجليزي

using System;
using System.Linq;
namespace exercises
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Original string: PHP");
            Console.WriteLine("Convert the letters of the said string into alphabetical order: " + test("PHP"));
            Console.WriteLine("Original string: javascript");
            Console.WriteLine("Convert the letters of the said string into alphabetical order: " + test("javascript"));
            Console.WriteLine("Original string: python");
            Console.WriteLine("Convert the letters of the said string into alphabetical order: " + test("python"));
        }
        public static string test(string str1)
        {
            return new string(str1.OrderBy(x => x).ToArray());
        }
    }
}

محتاج مساعدة؟ تواصل مع مدرس اونلاين الان!