Write a C# Sharp program to create a new string taking 3 characters from the middle of a given string at least 3

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

Write a C# Sharp program to create a new string taking 3 characters from the middle of a given string at least 3

Sample Output:

ell
yth
abc

الأجوبة

using System;
namespace exercises
{
   class Program
    {       
        static void Main(string[] args)
        {
            Console.WriteLine(test("Hello"));
            Console.WriteLine(test("Python"));
            Console.WriteLine(test("abc"));
            Console.ReadLine();
        }
        
      public static string test(string s1)
        {
           return s1.Substring((s1.Length - 1) / 2 - 1, 3);
        }
  }
}
هل كان المحتوى مفيد؟

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

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