Write a C# Sharp program to combine two given strings. If the given strings have different length remove the characters from the longer string
- برمجة سي شارب
- برمجة
- 2021-05-17
- MarwaMohammed
الأجوبة
using System;
namespace exercises
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(test("abc", "abcd"));
Console.WriteLine(test("Python", "Python"));
Console.WriteLine(test("JS", "Python"));
Console.ReadLine();
}
public static string test(string s1, string s2)
{
if (s1.Length < s2.Length)
{
return s1 + s2.Substring(s2.Length - s1.Length);
}
else if (s1.Length > s2.Length)
{
return s1.Substring(s1.Length - s2.Length) + s2;
}
else
{
return s1 + s2;
}
}
}
}أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال
