C# :: static void Main()

October 7th, 2008 by Mr.M | No Comments »

As I’m reading my Essential C# 3.0 book, it was going over the null and void thing. I understand how null works because I use it a lot in SQL, but void is kind of new to me.

Back in high school, I did some C++ stuff and managed to write a hangman program that doesn’t have an end loop. I then decided that I wanted to compile this C++ program into a .exe, which I did and then I stuck it in all the computer’s autoexec.bat file. hahaha, it was funny stuff.

Anyways, I might of forgotten what void did. The book said that void doesn’t return a value. I got a bit confused because the follow code returns 10 and I’m using the void thingy.

So I asked on the C# msdn forum and some nice people was able to set me straight. The method Main() doesn’t return any value when it exits the program. A sample syntax to cause the method to return something is as followed:

Much more to learn … before I can rule the world!

Leave a Reply

You must be logged in to post a comment.