Write a C# Sharp program to create a new string from a given string. If the two characters of the given string from its beginning and end are same return the given string without the first two characters otherwise return the original string
- برمجة سي شارب
- برمجة
- 2021-05-17
- MarwaMohammed
الأجوبة
using System;
namespace exercises
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(test("abcab"));
Console.WriteLine(test("Python"));
Console.ReadLine();
}
public static string test(string s1)
{
if (s1.Length > 1 && s1.Substring(0, 2) == s1.Substring(s1.Length - 2))
{
return s1.Substring(2);
}
else
{
return s1;
}
}
}
}
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال