Friday 26 September 2014

Revers Word in C#

namespace demo_arraylist
{
    class Program
    {
        static void Main(string[] args)
        {
            //Program that uses Array to Revers Word
            const string s1 = "This is Reverse word";   
            string rev1 = Words.RWords(s1);
            Console.WriteLine(rev1);
            Console.ReadKey();
        }
        //This is a method of Reverse
        static class Words
        {
            public static string RWords(string strword)
            {
                string[] words = strword.Split(' ');
                Array.Reverse(words);
                return string.Join(" ", words);
            }
        }
    }
}

No comments:

Post a Comment