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
- | م160
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
Sample Output:
cab Python
الأجوبة
ابحث عن مسائل برمجة سي شارب | c# programming بالانجليزي
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;
}
}
}
}
-
2021-05-17
- | MarwaMohammed
- | إبلاغ عن إساءة
أسئلة مشابهة