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.
ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
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();
}
}
ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
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.
Ryshad
Nearly a Posting Virtuoso
1,307 posts since Aug 2009
Reputation Points: 512
Solved Threads: 246