like

Monday, June 24, 2013

question asked in Interview 25/06/2013

WAP for reverse word with in a sentence?
WAP for find a hidden date in a string given by user?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace DreamOrbitTest
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter a string with date contining...");
            string szInput = Console.ReadLine();
            string[] arrInput = szInput.Split(' ');
             Array.Reverse(arrInput);
             Console.WriteLine("The final string is :");
             foreach (var item in arrInput)
             {
                 Console.Write(item);
             }
             Console.ReadKey();

            Console.WriteLine("Enter a string with hidden Date...");
            string szDateHidden = Console.ReadLine();
          
            // hhhkhk344455jkj01121988jkjkj

         
            string pattern = @"\d{2}\d{2}\d{4}";            // Split on date

            MatchCollection  substrings = Regex.Matches(szDateHidden, pattern);
            Console.WriteLine("Date found is :");
            foreach (var item in substrings)
            {
                Console.WriteLine(item);

            }
            Console.ReadKey();
        }
    }
}