Hi all, I'm newB in C# and kind of lost now since couldn't find the right/suitable references. Please correct me if I'm wrong...

My application will store values into database once user run it. In the Form Application, it runs well(no doubt). Now with the same approach, i want it run in the console application (this is try n error). So, I create new project in console and with same code, i copied, do some editing and put in Main. Luckily, the code running well.

My concerns are, is it what i'm doing is write? the command for the form can be used in console? What are differences between this two? is this the better approached?

Any advice and references are very helpful.

Why would anyone turn a working forms application, which can have all the whistles and bells you want, into a console application?

>the command for the form can be used in console? What are differences between this two? is this the better approached?

The console project template adds the necesary items needed to create a console application.
A console application is run from the command line with input and output information being exchanged between the command prompt and the running application. Because information can be written to and read from the console window, this make the console application a great a way to learn new programming techniques.

In order to write code against external component (library - DLL), your project must first contain a reference to it.

Comments
I agree!

I did mention that i'm a newB in C# programming. When i go through its tutorial, they did mention that c# can be running in console. So i just wanna see it in different approach. I dont think it's wrong when u wanna discover something new since i'm still beginner in this languages. But thanks for the advice.

I did mention that i'm a newB in C# programming. When i go through its tutorial, they did mention that c# can be running in console. So i just wanna see it in different approach. I dont think it's wrong when u wanna discover something new since i'm still beginner in this languages. But thanks for the advice.

Did you find that you could run the database interface in either console or Window's Form without problem?

It can be. I have service applications that use SQL connectors and as we all well know you cannot debug services. So for debugging I run my service application as a console application and when its ready to ship I just install it as a service.

You can run any code from any assembly really unless you get in to the presentation-layer specific code such as trying to instantiate a windows form in a web application, or a WebPage in a form application. For any of the System.Drawing and similar namespaces you just need to add a reference. VS doesn't add the same references to each project by default because more than likely you don't use drawing in a console application (unless you're writing a service that emails pictures and are running it as a dos application!).

It can be. I have service applications that use SQL connectors and as we all well know you cannot debug services. So for debugging I run my service application as a console application and when its ready to ship I just install it as a service.

You can run any code from any assembly really unless you get in to the presentation-layer specific code such as trying to instantiate a windows form in a web application, or a WebPage in a form application. For any of the System.Drawing and similar namespaces you just need to add a reference. VS doesn't add the same references to each project by default because more than likely you don't use drawing in a console application (unless you're writing a service that emails pictures and are running it as a dos application!).

I agree. I wonder why the smiling bear was so snappy.... Vinegar in his honey?

I agree. I wonder why the smiling bear was so snappy.... Vinegar in his honey?

He wasn't. Not everyone here knows english as their first language so sometimes it may just come across that way. Adatapost was just helping out. You'll know if he gets snappy :P

He wasn't. Not everyone here knows english as their first language so sometimes it may just come across that way. Adatapost was just helping out. You'll know if he gets snappy :P

Yea, you are probably right.:-/

This article has been dead for over six months. Start a new discussion instead.