Ruan10 0 Newbie Poster

I have to create a console application that asks the user to enter 6 words. These words must be stored in an array. When the user has entered the words, the application must send the first two words in the array to a web method. The web method must concatenate the two words and return the result. The result must then be sent to the web method with the third word and so on. The aim of this program is to concatenate the 6 words and display the result to the user.
The web service will have one method called concatWords(). The method should receive two strings as parameters and then return only one string. The final result should be calculated as follows.
If the user entered the words “hi” “I” “am” “your” “new” “friend”, the following should be displayed to the user.
Your word is: hiiamyournewfriend
This what I have done thus far:

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

namespace CFinalQ1
{
    class Program
    {        

        static void Main(string[] args)
        {
            //Create the Array
            string[] words = new string[6];

            //Tell the user to enter 6 words
            Console.WriteLine("Hi There, please enter six words");

            for (int i = 0; i < 6; i++)
            {
                String WordsConcat;//Declare a string variable

                Console.Write("Enter word and press Enter: ");//Tell the user to enter the next word
                words[i] = Console.ReadLine();//Add the word to the array
                Console.WriteLine(words[i] + " entered!");//Tell the user what word has been entered
                Console.WriteLine("");
                if (i == 1)
                {
                    WordsConcat = words[0] + words[1];//Change the value of the variable
                    Console.WriteLine("Your sentence looks like this: " + WordsConcat);//Show the user the current look of the sentence
                    Console.WriteLine("");
                }
                else if (i == 2)
                {
                    WordsConcat = words[0] + words[1] + words[2];//Value of the variable is changed
                    Console.WriteLine("Your sentence looks like this: " + WordsConcat);//Shows current look of the sentence
                    Console.WriteLine("");
                }
                else if (i == 3)
                {
                    WordsConcat = words[0] + words[1] + words[2] + words[3];//Change the value of the variable
                    Console.WriteLine("Your sentance looks like this: " + WordsConcat );//Look of the sentence is shown
                    Console.WriteLine("");
                }
                else if (i == 4)
                {
                    WordsConcat = words[0] + words[1] + words[2] + words[3] + words[4];//Change the value of the variable
                    Console.WriteLine("Your sentance looks like this: " + WordsConcat );//Current look of the sentence is shown to the user
                    Console.WriteLine("");
                }
                else if (i == 5)
                {
                    WordsConcat = words[0] + words[1] + words[2] + words[3] + words[4] + words[5];//Variable is changed
                    Console.WriteLine("Your sentance looks like this: " + WordsConcat );//Look of the sentence is shown to the user
                    Console.WriteLine("");
                }
            }
            Console.ReadLine();
        }
    }
}

I have not made use of a web method as I have no idea how to use it in this project. I need help on how to implement the web method as specified in the question. The coding above works correctly but I have to use a web method to pass the first 2 words from the array. Any help will be very much appreciated, you have no idea how much.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.