Wednesday 12 August 2015

How to reverse each word in the sentence using C#.net

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

namespace StringArray
{
    class Program
    {
        static void Main(string[] args)
        {
             string strWord = "Welcome to the New world";
            string strReverseword = string.Empty ;

            foreach (var word in strWord.Split(' '))
            {
                string dummy =string.Empty ;
                foreach (var ch in word.ToCharArray())
                {
                    dummy = ch + dummy;
                }
                strReverseword = strReverseword + dummy + " ";
            }
            Console.WriteLine(strReverseword);

            Console.ReadLine();
      }
    }
}



No comments:

Post a Comment