Uppercasing the first char with a StringBuilder. - CSharp Language Basics

CSharp examples for Language Basics:StringBuilder

Description

Uppercasing the first char with a StringBuilder.

Demo Code

using System;//from  w  w w  . j  a v  a 2s . c  o m
using System.Text;                // Need for type UTF8Encoding.
using System.Globalization;       // Need for cultures.
class Program
{
   static void Main(string[] args)
   {
      StringBuilder sb = new StringBuilder("jones");
      sb[0] = char.ToUpper(sb[0]);
      string fixedString = sb.ToString();
      Console.WriteLine("{0} becomes {1}", "jones", fixedString);
   }
}

Result


Related Tutorials