Q:

Write a C# program to create a new string from a given string (length 1 or more ) with the first character added at the front and back

0

Write a C# program to create a new string from a given string (length 1 or more ) with the first character added at the front and back

Sample Output:

Input a string : The quick brown fox jumps over the lazy dog.          
TThe quick brown fox jumps over the lazy dog.T

All Answers

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

using System;
using System.Text;

public class Exercise17 {
  static void Main(string[] args)
        {
           string str; 
           int l= 0;
           Console.Write("Input a string : ");
           str = Console.ReadLine();
           if (str.Length>=1)
           {
           var s = str.Substring(0,1);
           Console.WriteLine(s + str + s);
           }
        }
}

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