Search code examples
c#namespacesmonodevelop

MonoDevelop 4.0.1: Creating a new namespace in a project (on Windows 8.1 64-bit)


How do I create a namespace on MonoDevelop 4.0.1 for the same project?

I am following along the exercises from Practice Exercises C# Sharp where there are 11 lessons with multiple exercises each, and so far I am using only one namespace in the project. Instead of having all the programs I'd work on in the same namespace, I want to create multiple namespaces to make my project folder more organized.

I have more experience in Java, where you organize your source code and classes in independent packages. At one point, I came across this StackOverflow question where it only tells me the difference between a Java package and a C# namespace.


Solution

  • With C#, the namespace is declared in the source file:

     namespace My.Namespace.Name
     {
     }
    

    You can have as many of those blocks as you want in a file and you do not need to have a matching folder structure like you do in Java.