Checks whether the first letter of each word is capitalized - CSharp System

CSharp examples for System:String Case

Description

Checks whether the first letter of each word is capitalized

Demo Code


using System.Text.RegularExpressions;
using System.Text;
using System.Globalization;
using System.Collections.Generic;
using System;/*from ww w  . jav a  2s  . c o  m*/

public class Main{
        // Checks whether the first letter of each word is capitalized
        //The Big Story -> True
        //The big story -> False
        public static bool IsTitle(string input)
        {
            string[] words = input.Split(new char[] { ' ' });

            for (int i = 0; i < words.Length; i++)
            {
                if (words[i].Length > 0)
                    if (String.Compare(words[i].Substring(0, 1).ToUpper(), words[i].Substring(0, 1), false) != 0)
                        return false;
            }
            return true;
        }
}

Related Tutorials