Write a C# Sharp program to create a new string where 'if' is added to the front of a given string. If the string already begins with 'if', return the string unchanged
- برمجة سي شارب
- برمجة
- 2021-05-16
- MarwaMohammed
الأجوبة
using System;
namespace exercises
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(test("if else"));
Console.WriteLine(test("else"));
Console.ReadLine();
}
public static string test(string s)
{
if (s.Length > 2 && s.Substring(0, 2).Equals("if"))
{
return s;
}
return "if " + s;
}
}
}
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال
