Click here to Skip to main content
16,004,602 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Is it possible using more than one main in .cs file and how to compile and run it?
Posted

You should really only have one main method. You can achieve essentially the same thign as what using the "mutlimain" approach gives you with compiler definitions, or even commandline parameters. There is no logical reason to have two main methods in an application. Beyond al that, it becomes a maintenance issue.

In short - it's bad practice, and just a plain bad idea. My advice - find another way.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 6-Jan-11 13:49pm    
John, I agree completely, but there is something essential to know about it: what is entry point is defined in the project property. -- please see my answer to another Question of this member about "multimain".
Thank you.
Sergey Alexandrovich Kryukov 6-Jan-11 14:04pm    
Therefore I credited your answer in my answer to the same member.
I voted 5 for yours.
Yes it is possible.

See THIS[^] having exact what you need.
 
Share this answer
 
Comments
Richard MacCutchan 7-Jan-11 7:19am    
Except the syntax is slightly wrong; see my answer to OP's second question on this subject.
Go through the below link

Here[^]
Here[^]
 
Share this answer
 
Comments
#realJSOP 6-Jan-11 7:32am    
Neither of these links help the OP.
Rajesh Anuhya 6-Jan-11 7:33am    
@John Simmons / outlaw programmer
are see this links .., or you blindly voted??
#realJSOP 6-Jan-11 8:25am    
Yes, I went to the links, an d they don't answer the OP's question. Hiren Solanki's answer *did* answer the question. My answer is to not do it at all, and to find anothger way.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900