1
// This is traditionally the first program written
using System;
namespace HelloWorldProgram
{
    class HelloWorld
    {
        static void Main()
        {
            Console.WriteLine("Hello World!");
        }
    }
}

I dont get why the statements in the body end with a " ; " but nothing is placed at the end of method headings. Guess this is the pain as a beginner in programming.....

Thanks Again !

Edited by techlawsam: didnt know there was "code" script so formatting is now better

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by Momerath
2

{} indicates a block of code so the compiler knows that it ends when it reaches a closing }. ';' is used to mark the end of a statement so the compiler knows that you are done with that statement since C# ignores white space (except where significant). You could write

class
HelloWorld
{
static
void
Main()
{
Console.WriteLine(
"Hello World!"
)
;
}

As you get into more advanced programming, you'll find a few places where you have to type "};" :)

Edited by Momerath: n/a

Votes + Comments
Simplicity :)
Nice aswer! :)
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.