Creating Pascal Case or Upper case First character in string using C#

In this blog we are going to see, how to create Pascal Case string using C#.

Usage:

  Response.Write(UppercaseFirst("lajapathy "));

  Response.Write(UppercaseFirst("arun"));

 

Code Snippet:

public string UppercaseFirst(string s)

        {

            // Check for empty string.

            if (string.IsNullOrEmpty(s))

            {

                return string.Empty;

            }

            // Return char and concat substring.

            return char.ToUpper(s[0]) + s.Substring(1);

        }

 

Output:

Lajapathy Arun

Ebook Download
View all
Learn
View all