Write a C# Sharp program to remove the first and last elements from a given string
- برمجة سي شارب
- برمجة
- 2021-05-15
- MarwaMohammed
الأجوبة
using System;
namespace exercises
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Original string: PHP");
Console.WriteLine("After removing first and last elements: "+test("PHP"));
Console.WriteLine("Original string: Python");
Console.WriteLine("After removing first and last elements: " + test("Python"));
Console.WriteLine("Original string: JavaScript");
Console.WriteLine("After removing first and last elements: " + test("JavaScript"));
}
public static string test(string str1)
{
return str1.Length > 2 ? str1.Substring(1, str1.Length - 2) : str1;
}
}
}
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال