Write a C# Sharp program to create a new string with the last char added at the front and back of a given string of length 1 or more

  • برمجة سي شارب
  • برمجة

Write a C# Sharp program to create a new string with the last char added at the front and back of a given string of length 1 or more

Sample Output:

dRedd
nGreenn
111

الأجوبة

using System;

namespace exercises
{
  class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(test("Red"));
            Console.WriteLine(test("Green"));
            Console.WriteLine(test("1"));
            Console.ReadLine();
        }

        public static string test(string str)
        {
            var s = str.Substring(str.Length-1);
            return s + str + s;
        }
    }
}
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...