Novice working with C#. Opened a project file to commence lessons with the Head First C# programming eBook. When reopened errors were found. Images are uploaded to a microsoft skydrive folder:
https://skydrive.live.com/redir?resid=52B21D2F3F75A51A!1427

Hoping that someone experienced can stay with me until I can grasp each error and know precisely where to place the remedies. Ideally I would want guidance on the first of the five issues then proceed. The errors read as follows:

**1.The file C:\Users\maurice\Documents\Visual Studio 2010\Projects\Head First IDE Lab\Head First IDE Lab1\Form2.cs does not support code parsing or generation because it is not contained within a project that contains code

2.A namespace cannot directly contain members such as fields or methods

3.Type or namespace definition, or end of file expected

  1. A namespace cannot directly contain members such as fields or methods

5 Type or namespace definition, or end of file expected **

As a complete beginner, I do not know precisely where to go to and how to remedy each of the above errors.

Additionally, I do no know the finer points of posting e.g. the code an inline code.

Recommended Answers

All 2 Replies

It sounds like your class definition is incorrect. You would have forgotten a { or } somewhere and so your class or methods don't properly close. A sample class would look like this:

namespace SampleNamespace
{
    class SampleClass
    {
        public void SampleMethod()
        {
            System.Console.WriteLine(
              "SampleMethod inside SampleNamespace");
        }
    }
}

One or more of the curly braces being missed would cause the errors you are seeing. Check everything is where it should be. Basically your namespace holds a class with {}, and a class holds your fields and methods inside a pair as well.

First error is telling you that Form2.cs isn't part of the project. I don't see it in the solution box so I'd say it's right.

Second error was covered above. We can't tell you exactly what the problem was because you don't show us the lines where the errors occur.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.