Extract only letters from given input

Omniitstudent
Posted by Omniitstudent under C# category on | Points: 40 | Views : 1199
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication28
{

class Program
{

static void Main(string[] args)
{
Console.WriteLine("Enter Input");
string str = Console.ReadLine();
int nNd = 0;
string sOnlyString = string.Empty;
for (int i = 0; i <str.Length; i++)
{
if ((str[i]>='a'||str[i]>='A') &&(str[i]>='Z'||str[i]>='z'))
{
nNd++;
sOnlyString += str[i];
}

}

Console.WriteLine("Total no character in the string is"+nNd);
Console.WriteLine("String without digits "+sOnlyString);



Console.ReadLine();
}

}


}
==============

input #234dotnet345funda
output 11
dotnetfunda

Comments or Responses

Login to post response