Checks whether a string is in all upper case - CSharp System

CSharp examples for System:String Case

Description

Checks whether a string is in all upper case

Demo Code


using System.Text.RegularExpressions;
using System.Text;
using System.Globalization;
using System.Collections.Generic;
using System;//from   www .  j  av  a  2s.c o m

public class Main{
        //Checks whether a string is in all upper case
        //word -> False
        //Word -> False
        //WORD -> True
        public static bool IsUpperCase(string input)
        {
            for (int i = 0; i < input.Length; i++)
            {
                if (String.Compare(input.Substring(i, 1), input.Substring(i, 1).ToUpper(), false) != 0)
                    return false;
            }
            return true;
        }
}

Related Tutorials