This is very interesting and logic building program in C# for beginners. The program will count only letters in a given strings e.g. a1B2C456 has only 3 Letters.
Source Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace assad
{
class countLetters
{
static void Main(string[] args)
{
welcomeScrean();
String str = "A1B2C36gfhf5";
int numberOfLetters = 0;
foreach (char letter in str)
{
if (Char.IsLetter(letter))
numberOfLetters++;
}
Console.WriteLine("\tStriing " + str + " has " + numberOfLetters + " letters.");
int ab = Console.Read();
}
private static void welcomeScrean()
{
Console.ForegroundColor = ConsoleColor.Magenta;
Console.Write("\t*******************************************************" + "\n"
+ "\t*******************************************************" + "\n"
+ "\t** Welcome To **" + "\n"
+ "\t** Count Letters **" + "\n"
+ "\t** Program **" + "\n"
+ "\t*******************************************************" + "\n"
+ "\t*******************************************************\n\n\n\n");
}
}
}
0 comments:
Post a Comment