Write a C# Sharp program to create a new string which is 4 copies of the 2 front characters of a given string. If the given string length is less than 2 return the original string
- برمجة سي شارب
- برمجة
- 2021-05-16
- MarwaMohammed
الأجوبة
using System;
namespace exercises
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(test("C Sharp"));
Console.WriteLine(test("JS"));
Console.WriteLine(test("a"));
Console.ReadLine();
}
public static string test(string str)
{
return str.Length < 2 ? str : str.Substring(0, 2) + str.Substring(0, 2) + str.Substring(0, 2) + str.Substring(0, 2);
}
}
}أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال
