How to display output window in Windows application format using C #?

I cannot display the output window, can someone tell me what I am missing here? I am trying to display a #pyramid-shaped symbol .

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

namespace variable
{
    class Program
    {
        static void Main()
        {
            for (int row = 0; row < 6; row++)
            {
                // Counting backwards here!
                for (int spaces = 6 - row; spaces > 0; spaces--)
                {
                    Console.Write(" ");
                }

                for (int column = 0; column < (2 * row + 1); column++)
                {
                    Console.Write("#");
                }
                Console.WriteLine();
            }
            Console.Read();
        }
    }
}
+3
source share
2 answers

I assume that you configured the project as a Windows forms project.

So you do not have a console.

You have three options:

  • Set the project type to Console application . This is most likely not possible because your application will require too many changes.
  • , P/Invoke. . Windows?. 3. , .
  • Trace.Write/Debug.Write Visual Studio.
+1

} Console.Read();

, .

using System.IO;
using System;
class Program
{
    static void Main()
    {
        // Read in every line in the file.
        for (int row = 0; row < 6; row++)
        {
                // Counting backwards here!
            for (int spaces = 6 - row; spaces > 0; spaces--)
            {
                Console.Write(" ");
            }

            for (int column = 0; column < (2 * row + 1); column++)
            {
                Console.Write("#");

            }

             Console.WriteLine();
         }
         Console.Read();
    }
}

:

      #
     ###
    #####
   #######
  #########
 ###########
-1

All Articles