Q:

Write a C# program to create a new string where the first 4 characters will be in lower case. If the string is less than 4 characters then make the whole string in upper case

0

Write a C# program to create a new string where the first 4 characters will be in lower case. If the string is less than 4 characters then make the whole string in upper case

Sample Output:

Input a string: w3r                                                    
W3R

All Answers

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

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class Exercise42
{
    public static void Main( )
    {
        Console.Write("Input a string: ");
        string str = Console.ReadLine();
         if (str.Length < 4) 
           Console.WriteLine(str.ToUpper());
         else
           Console.WriteLine(str.Substring(0, 4).ToLower() + str.Substring(4, str.Length -4));
    }
}

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