Saturday, July 16, 2011

Check Character in c sharp

using System;

namespace csharp.Example.System
{
public class DeterminingCharType
{
public static void Main(string[] args)
{
    Console.WriteLine("please enter character");
char c = Convert.ToChar(Console.ReadLine());

if (Char.IsDigit(c))
{
Console.WriteLine("Char " + c + " is digit");
}
else if (Char.IsNumber(c))
{
Console.WriteLine("Char " + c + " is number");
}
else if (Char.IsSeparator(c))
{
Console.WriteLine("Char " + c + " is separator");
}
else if (Char.IsSymbol(c))
{
Console.WriteLine("Char " + c + " is symbol");
}
else if (Char.IsControl(c))
{
Console.WriteLine("Char " + c + " is control");
}
else if (Char.IsLetter(c))
{
Console.WriteLine("Char " + c + " is letter");
}
else if (Char.IsPunctuation(c))
{
Console.WriteLine("Char " + c + " is punctuation");
}
else if (Char.IsSurrogate(c))
{
Console.WriteLine("Char " + c + " is surrogate");
}
else if (Char.IsWhiteSpace(c))
{
Console.WriteLine("Char " + c + " is whitespace");
}

Console.ReadLine();
}
}
}

No comments:

Post a Comment

Your comment is pending for approval

AngularJS Basics - Part 1

                                                                  AngularJS What is AngularJS ·          Framework by googl...