Char structure

Check upper lower case letters in string

You can use the IsUpper(char c) or IsLower(char c) methods to check a character if it is an upper case or it is a lower case letter.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ConsoleApplication1
{
class Program
{

static void Main(string[] args)
{
string st = "C# programming";
int countupper = 0,countlower=0,i;
for (i = 0; i < st.Length; i++)
if (Char.IsUpper(st[i])) countupper++;
else if (Char.IsLower(st[i])) countlower++;
Console.WriteLine("Number of upper case letters:{0}", countupper);
Console.WriteLine("Number of upper case letters:{0}", countlower);
Console.ReadLine();


}

}
}




HTML Comment Box is loading comments...



This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.