?
Solved

void Main() or int Main() with return 0

Posted on 2003-10-27
2
Medium Priority
?
216 Views
Last Modified: 2010-04-16
I once read that in C++ it is better programming practice to use int main() with a return 0 rather than using void main.  Is this true and if so is it true of C# as well?  I have looked at many tutorials on C# and found one that used the int return way.
0
Comment
Question by:chilled2003
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 15

Accepted Solution

by:
SRigney earned 100 total points
ID: 9629289
In my opinion it depends on what you will be doing with your application.

If you are writing anything that will be called from a command line, batch file, or DTS Schedule then using a return value would be better because the return value will be provided to the callers, and allow them to make decisions based on the value.

0 is considered no error any non zero number is considered an error.

If you are just writing a GUI then there would be no difference between return 0 and void main.
0
 
LVL 10

Expert Comment

by:ptmcomp
ID: 9629754
As long the return value is not used it doesn't matter. If your calling from a batch file and returning a result use int main().
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question