Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

C# Sharp Exercises: Convert the first character of each word of a given string to uppercase

C# Sharp String: Exercise-52 with Solution

Write a C# Sharp program to convert the first character of each word of a given string to uppercase.

Letter case is the distinction between the letters that are in larger uppercase or capitals and smaller lowercase in the written representation of certain languages.

Sample Solution:-

C# Sharp Code:

using System;
using System.Linq;
namespace exercises
{
    class Program
    {
        static void Main(string[] args)
        {
            string str1 = "python exercises";
            Console.WriteLine("Original string: " + str1);
            Console.WriteLine("After converting the first character of each word of the said string:\n" + test(str1));
            str1 = "The quick brown Fox jumps over the little lazy Dog";
            Console.WriteLine("\nOriginal string: " + str1);
            Console.WriteLine("After converting the first character of each word of the said string:\n" + test(str1));
        }
        public static string test(string str1)
        {
            return string.Join(" ", str1.Split(' ').Select(str1 => char.ToUpper(str1[0]) + str1.Substring(1)));
        }
    }
}

Sample Output:

Original string: python exercises
After converting the first character of each word of the said string:
Python Exercises
Original string: The quick brown Fox jumps over the little lazy Dog
After converting the first character of each word of the said string:
The Quick Brown Fox Jumps Over The Little Lazy Dog

Flowchart :

Flowchart: C# Sharp Exercises - Convert the first character of each word of a given string to uppercase.

C# Sharp Code Editor:

Improve this sample solution and post your code through Disqus

Previous:Write a C# Sharp program to check whether a given string is an "isograms" or not. Return True or False.
Next: Write a C# Sharp program to find the position of a specified word in a given string.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.