hi im trying to create a C# program that'll display

*
**
***
****
***
**
*

type pattern but i can only get mine to look like this when i try to add on to the code

*
**
***
****

and then it stops. can anyone help on how im supposed to add the second part of the code??

// week 05 program 01
// creating a simple pattern of asterisks
using System;
using System.Text;
 
namespace AsterisksPattern
{
    class Asterisks
    {
        public static void Main(string[] args)
        {
           // start loop from 0
           for (int x = 0; x < 26; x++)
           {
              for (int y = 0; y <= x; y++)
              {
                 Console.Write("*");
              }
                 Console.WriteLine();
            }
                 Console.ReadLine();
        } // end Main
    } // end class
} // end of namespace

Hi, rzhaley, welcome on DANIWEB:)
Copy your for loops code and paste it underneath. Change the for loop with the int x in this: for (int x = 26; x > 0; x--) you start from 26 and counting down now.

hi thanks...... i figured it was like that but im confused on which line to put this in my code wherever i try it just gives me new errors

Now when you watch carefully you will see the use of the same code twice. Whenever you see that you must start thining of using a method to make your code more transparant and manageable. Considr you have hunderd lines of code used More times on different places in your program. Very hard to maintain!!!
Here is what I did:

class Program
    {
        static void Main(string[] args)
        {
            // start loop from 0           
            for (int x = 0; x < 26; x++)           
            {    
                WriteStars(x);       
            }
            // start loop from 26
            for (int x = 26; x > 0; x--)
            {
                WriteStars(x);
            }
            Console.ReadLine();
        }

        //method to write a line of n stars to the console
        static void WriteStars(int n)
        {
            for (int y = 0; y <= n; y++)
            {
                Console.Write("*");
            }
            Console.WriteLine();
        }
    }

THANKYOU makes much more sense

Hi,
As a new member, b e sure to check out Member Rules. There are some guidlines in there for posting to the forums.
One of those rules is to use descriptive titles for threads. "****" doesnt tell forum users what your thread is about. By using decriptive titles you are more likely to get the help you need :)
Also, once your question has been answered, remember to mark the thread as solved.

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.