Пример #1
0
        public string MergeWord()
        {
            int Lngt1 = Word1.Length, Lngt2 = Word2.Length; //Get the length of both words

            if (Lngt1 == Lngt2)                             //When both words have the same length
            {
                for (int x = 0; x < Lngt1; x++)
                {
                    NewWord = NewWord + Word1.Substring(x, 1) + Word2.Substring(x, 1);
                }
            }
            else if (Lngt1 > Lngt2)  //When the first word is bigger than the second one
            {
                for (int x = 0; x < Lngt2; x++)
                {
                    NewWord = NewWord + Word1.Substring(x, 1) + Word2.Substring(x, 1);
                }
                for (int x = Lngt2; x < Lngt1; x++)
                {
                    NewWord = NewWord + Word1.Substring(x, 1);
                }
            }

            else //When the second word is bigger than the first one
            {
                for (int x = 0; x < Lngt1; x++)
                {
                    NewWord = NewWord + Word1.Substring(x, 1) + Word2.Substring(x, 1);
                }
                for (int x = Lngt1; x < Lngt2; x++)
                {
                    NewWord = NewWord + Word2.Substring(x, 1);
                }
            }
            return(NewWord);
        }