Extract all digits from given input

Omniitstudent
Posted by Omniitstudent under C# category on | Points: 40 | Views : 1204
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 sOnlydigits = string.Empty;
for (int i = 0; i <str.Length; i++)
{
if ((str[i]>=48 &&str[i]<=57))
{
nNd++;
sOnlydigits += str[i];
}

}

Console.WriteLine("Total no of digits in the string is"+nNd);
Console.WriteLine("String without characters " + sOnlydigits);



Console.ReadLine();
}

}


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

input-- 9023@tup21
output-- 6
out put--902321


crazy code

Comments or Responses

Login to post response