Write a C# Sharp program to create a new string of the first half of a given string of even length

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

Write a C# Sharp program to create a new string of the first half of a given string of even length

Sample Output:

He
H

الأجوبة

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

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

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