Write a C# program to create a new string from a given string where the first and last characters will change their positions
- برمجة سي شارب
- برمجة
- 2021-05-14
- MarwaMohammed
الأجوبة
using System;
using System.Collections.Generic;
public class Exercise16 {
static void Main(string[] args)
{
Console.WriteLine(first_last("w3resource"));
Console.WriteLine(first_last("Python"));
Console.WriteLine(first_last("x"));
}
public static string first_last(string ustr)
{
return ustr.Length > 1
? ustr.Substring(ustr.Length - 1) + ustr.Substring(1, ustr.Length - 2) + ustr.Substring(0, 1) : ustr;
}
}
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال
