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

  • برمجة سي شارب
  • برمجة

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

الأجوبة

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));
    }
}
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...