Show string in proper case : String Split : Data Types C# Source Code


Custom Search

C# Source Code » Data Types » String Split »

 

Show string in proper case








    
 

using System;
using System.Text;
public class StringEx
{
    public static string ProperCase(string s)
    {
        s = s.ToLower();
        string sProper = "";
   
        char[] seps = new char[]{' '};
        foreach (string ss in s.Split(seps))
        {
            sProper += char.ToUpper(ss[0]);
            sProper += 
            (ss.Substring(1, ss.Length - 1) + ' ');
        }
        return sProper;
    }
}
   
class MainClass
{
    static void Main(string[] args)
    {
        string s  = "tHE test";
        Console.WriteLine("Initial String:\t{0}", s);
   
        string t = StringEx.ProperCase(s);
        Console.WriteLine("ProperCase:\t{0}", t);
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Data Types
» String Split