Write a C# Sharp program to create a new string from a give string where a specified character have been removed except starting and ending position of the given string
- برمجة سي شارب
- برمجة
- 2021-05-16
- MarwaMohammed
الأجوبة
using System;
using System.Linq;
namespace exercises
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(StringX("xxHxix", "x"));
Console.WriteLine(StringX("abxdddca", "a"));
Console.WriteLine(StringX("xabjbhtrb", "b"));
Console.ReadLine();
}
public static string StringX(string str1, string c)
{
for (int i = str1.Length - 2; i > 0; i--)
{
if (str1[i] == c[0])
{
str1 = str1.Remove(i, 1);
}
}
return str1;
}
}
}
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال