Q:

Write a C# Sharp program to create a new string using three copies of the last two character of a given string of length atleast two

0

Write a C# Sharp program to create a new string using three copies of the last two character of a given string of length atleast two

Sample Output:

lololo
HiHiHi

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;
namespace exercises
{
   class Program
    {       
        static void Main(string[] args)
        {
            Console.WriteLine(test("Hello"));
            Console.WriteLine(test("Hi"));
            Console.ReadLine();
        }        
         public static string test(string s1)
         {
            string last2 = s1.Substring(s1.Length - 2);
            return last2 + last2 + last2;
         }
  }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now