Answer to Question #272762 in C# for Hilok

Question #272762

9. The text is given. Display the numbers in the text.

1
Expert's answer
2021-11-30T07:17:38-0500
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;


namespace App
{
    class Program
    {




        public static void Main()
        {




            Console.Write("Enter the text: ");
            string text= Console.ReadLine();
            string[] numbers = Regex.Split(text, @"\D+");
            foreach (string value in numbers)
            {
                if (!string.IsNullOrEmpty(value))
                {
                    int i = int.Parse(value);
                    Console.WriteLine("Number: {0}", i);
                }
            }
            Console.ReadLine();
        }


    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS