How do I determine if character is in lower or upper case?

Category: System, viewed: 998 time(s).

Use System.Char IsLower() or IsUpper() static method to determine character case.

using System;

namespace Kodecsharp.Example.System
{
    public class LowUpperCase
    {
        public static void Main(string[] args)
        {
            string phrase = "The Quick Brown Fox Jumps Over The Lazy Dog";
            char[] chars = phrase.ToCharArray();

            for (int i = 0; i < chars.Length; i++)
            {
                char c = chars[i];
                if (Char.IsLetter(c))
                {
                    if (Char.IsLower(c))
                    {
                        Console.WriteLine(c + " is lowercase");
                    }
                    else if (Char.IsUpper(c))
                    {
                        Console.WriteLine(c + " is uppercase");
                    }
                }
            }

            Console.ReadLine();
        }
    }
}
Download Hundreds of Complimentary Industry Resources

Get hundreds of popular Industry magazines, white papers, webinars, podcasts, and more; all available at no cost to you. With more than 600 complimentary offers, you'll find plenty of titles to suit your professional interests and needs. Click Here and Sign up today!

Our Friends

Network Sites

Statistics

Locations of visitors to this page