Elliot678
Elliot678

Reputation: 348

Getting " type of namespace definition, or end-of-file expected error"

using System;

namespace test

{
    public class multiplying
    {   
        public static void Main( string[] args);
        { //getting invalid '{' token here 
            int number1;
            int number2;
            int total;

        }
    }
} // getting type of namespace definition, or end-of-file expected error here 

The programme isn't finished obviously but when I write more in I just get more errors so there must be something wrong here but I don't know what.

Upvotes: 0

Views: 6320

Answers (5)

Brendan Long
Brendan Long

Reputation: 54302

I'm not that familiar with C#, but I think this is your problem:

    public static void Main( string[] args);
    { //getting invalid '{' token here 

; is ending the declaration, so the { is considered completely separate (and don't make sense without a function signature coming first. Try changing it to this:

    public static void Main( string[] args)
    {

Upvotes: 2

Jonny
Jonny

Reputation: 2927

You have an extra semi-colon here : public static void Main( string[] args);

Upvotes: 3

Sascha
Sascha

Reputation: 10347

You have a ; after the closing bracket of the argument list.

Upvotes: 1

BrokenGlass
BrokenGlass

Reputation: 160982

public static void Main( string[] args);

You have an extra ; there.

Upvotes: 2

Joe
Joe

Reputation: 82654

public static void Main( string[] args);

should be

public static void Main( string[] args)

Upvotes: 4

Related Questions