954,505 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Console App?

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());
        }
    }
}
complete
Junior Poster
153 posts since Dec 2005
Reputation Points: 17
Solved Threads: 0
 

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!
        }
    }
}
Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
 

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.

Infarction
Posting Virtuoso
1,580 posts since May 2006
Reputation Points: 683
Solved Threads: 53
 

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

abdulsamix
Newbie Poster
2 posts since Jan 2008
Reputation Points: 10
Solved Threads: 0
 

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.

Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You