c# string first character uppercase

c# string first character uppercase

You want to make the first character of the string to upper case. Here is simple C# program that coverts first character if the string to upper case.

First character To upper case Example

using System;

namespace Csharp.Month.String.ToInt.Example
{
    class Program
    {
        static void Main(string[] args)
        {
          
          string name = "asp.net";
          
           name =  name[0].ToString().ToUpper() + name.Substring(1);
          
Console.WriteLine( "converted asp.net string to first character uppercase " + name );
          Console.ReadLine();
              
        }
 
    }
 
}

Another example that converts first character of the string to upper case

using System;

namespace Csharp.Month.String.ToInt.Example
{
    class Program
    {
        static void Main(string[] args)
        {
          
          string name = "asp.net";
          
           char []charArray = name.ToCharArray() ;
           charArray[0] = char.ToUpper( charArray[0]);
           
           name = new string(charArray);
           
          
          Console.WriteLine( "First character uppercase " + name );
          Console.ReadLine();
              
        }
 
    }
 
}
C# DateTime ToString()[C#] Remove Last Character From StringReplace string in C#c# stringC# foreach loopSplit String In C#How To Declare and access array of string in C#.net String vs stringAsp.net Convert String To ImageC# Get Character from StringC# Binary To String

Author

My name is Satalaj, but people call me Sat. Here is my homepage: . I live in Pune, PN and work as a Software Engineer. I'm former MVP in ASP.net year 2010.
Disclaimer: Views or opinion expressed here are my personal research and it has nothing to do with my employer. You are free to use the code, ideas/hints in your projects. However, you should not copy and paste my original content to other web sites. Feel free to copy or extend the code.
If you want to fight with me, this website is not for you.
 

I'm Satalaj.