The sample code I am looking at is supposed
to be a console app. And yet it has the
same sort of structure that a windows app
would have.

Since I am unable to build the app yet, I
am unsure if it is a true console app.

Can a console app have this sort of main
procedure structure?

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

namespace SomeProductNameSample
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
        }
    }
}

Recommended Answers

All 4 Replies

It's a windows application!

Console is

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

namespace SomeProductNameSample
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
///any code begins from here!
        }
    }
}

In some simple cases, a console app will simply have its implementation begin in the Main() method, whereas a Winforms project requires the form to be instantiated in Main() and have the implementation elsewhere. So, I would agree with you that it looks like you have a Winforms project on your hands.

No, you cant have.......but you can start a windows app from console by adding the required code..

OK, we have no objection!! we faced a question and we answered!!
The code written in the question is Windows Application code not Console one.

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.