A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Write a C# Sharp program to create a new string using the first and last n characters from a given string of length at least n
Q:

Write a C# Sharp program to create a new string using the first and last n characters from a given string of length at least n

0

Write a C# Sharp program to create a new string using the first and last n characters from a given string of length at least n.

Sample Output:

Ho
Pyon
on
oo

 

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", 1));
            Console.WriteLine(test("Python", 2));
            Console.WriteLine(test("on", 1));
            Console.WriteLine(test("o", 1));
            Console.ReadLine();
        }
        
         public static string test(string s1, int n)
         {
             return s1.Substring(0, n) + s1.Substring(s1.Length - n);
         }
  }
}

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