Alex Gordon
Alex Gordon

Reputation: 60691

c#- what steps do i have to go through to convert winform app into console

i have a very simple winforms application.

i do not use the forms object at all. i would like to know what i need to delete or change in order to convert this app to a console. i mainly just need to get rid of all the unneeded references and such

please let me know what steps i should take to do this?

Upvotes: 0

Views: 122

Answers (3)

Bibhu
Bibhu

Reputation: 4081

You can change the project settings to create a Console Application instead of a Windows Application (just hit Ctrl+Enter on the project in the Solution Window, and make that change).

That will compile the application as a Console Application, and you'll get a console. However, you'll still get your forms. If you want to not have Windows Forms, you'll need to remove the forms, and replace their functionality with command line arguments or configuration. You can then remove the Windows Forms references, and it'll be converted.

Upvotes: 0

Orn Kristjansson
Orn Kristjansson

Reputation: 3485

Create console app and move the simple code over

Upvotes: 0

PedroC88
PedroC88

Reputation: 3829

It really depends on how did you code it at first and what pattern are you using. If you have made clear distinctions of what is the back-end and what's not, then you would only have to create a new class to act as the program's Main and change the project's Application Typeand the Startup Object in the project's properties.

If you have all the back-end code intertwined with the winforms then you first need to separate them and then proceed to with the above steps.

Upvotes: 2

Related Questions