Пример #1
0
        public static void GetReverseString()
        {
            //declaring string for reverse.
            Console.WriteLine("--------------------");
            Console.WriteLine("print reverse string");
            Console.WriteLine("--------------------");
            string sentense      = "I eat";
            string reverseString = "";

            //printing reverse string
            Console.WriteLine("The input string is: {0}", sentense);
            //calling ReverseString class
            Console.WriteLine("The reverse string of the input is: {0}", Reverse.StringReverse(sentense));
        }
Пример #2
0
        public static void GetReverseStringLastWord()
        {
            Console.WriteLine("\n");
            Console.WriteLine("------------------------");
            Console.WriteLine("print 'I eat' to 'I tae'");
            Console.WriteLine("------------------------");
            //declaring string for reverse.
            string sentense      = "I eat";
            string reverseString = "";

            //declare the seperator
            char[] seperator = { ' ' };
            //split the sentence with space
            String[] stringList = sentense.Split(seperator);
            //calling reverse method and concatenating with 1st string
            reverseString = stringList[0] + ' ' + Reverse.StringReverse(stringList[1]);
            //printing the reverse string
            Console.WriteLine("The reverse string(Last word) of the input is: {0}", reverseString);
        }
Пример #3
0
        static void Main(string[] args)
        {
            //--------------------
            //print reverse string
            //--------------------
            Reverse.GetReverseString();

            //--------------------------
            //print "I eat" to "I tae"
            //--------------------------
            Reverse.GetReverseStringLastWord();

            //-------------------------------------------------------------------------
            // Take input from file where each line contains a integer and find average
            //-------------------------------------------------------------------------
            ReadFile.GetSum();

            //----------------------------
            // Reverse a string word wise.
            //----------------------------
            Reverse.GetReverseStringWordWise();
        }