Click here to Skip to main content
15,880,503 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
error CS1022: Type or namespace definition, or end-of-file expected.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using ChartboostSDK;

namespace game{

void Start() {
Chartboost.showInterstitial(CBLocation.HomeScreen);
Invoke("showInterstitial", 60.0f);

}
}
}


What I have tried:

I placed extra brackets but still the same error. 
Posted
Updated 28-Jan-20 10:30am

1 solution

This is why it's important to properly indent your code. As a beginner, I would NOT put the curly braces on the same line as what's being defined. Put them on the next line so you can easily see which opening and closing braces should line up with each other.

In C#, all code MUST be in a class. You don't have a class defined, so you have to create one.

Your code should look more like:
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using ChartboostSDK;

namespace game
{
    public class MyClass
    {
        void Start()
        {
            Chartboost.showInterstitial(CBLocation.HomeScreen);
            Invoke("showInterstitial", 60.0f);
        }
    }
}
 
Share this answer
 
Comments
OriginalGriff 28-Jan-20 16:46pm    
:) As a side, your choice of brace positioning is triggering my OCD. I have a compulsion to move the braces right a tab.
Dave Kreskowiak 28-Jan-20 16:57pm    
LOL :)

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