# Namespaces

### <span style="color: #3598db;">What are namespaces?</span>

<p class="callout info">Namespaces are a fundamental feature in C# and are used to control the scope of your projects.</p>

<p class="callout success">When developing anything with UdonSharp, declaring your own namespaces should be one of the first steps of your development process.</p>

<p class="callout warning">If a creator doesn't declare their own namespace for their UdonSharpBehaviours, all of their classes will be exposed to the entire project by default and may cause misunderstandings and confusion, especially amongst beginners.</p>

<p class="callout info">[https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/types/namespaces](https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/types/namespaces)</p>

---

### <span style="color: #3598db;">How to declare a namespace in UdonSharp?</span>

In order to declare your own namespace for a project, all you have to do is encapsulate your class in curly brackets, lead by the ***namespace*** keyword and your desired namespace.

```C#
namespace Varneon.ExamplePrefab
{
	public class ExampleClass : UdonSharpBehaviour
    {
    
    }
}
```

<p class="callout success">It is highly recommended to always have the first element of the namespace be your own name (or brand, if you have one).</p>

<p class="callout warning">DO NOT use anyone else's name for the namespace unless you are working on the project for them!</p>

---

### <span style="color: #3598db;">How to access classes in other namespace?</span>

In order to access classes in other namespaces, all you have to do is use the ***using*** keyword to extend the scope of your project to that other namespace

```C#
using Varneon.ExamplePrefab;

namespace Varneon.OtherExamplePrefab
{
	public class OtherExampleClass : UdonSharpBehaviour
    {
    	private ExampleClass exampleClass;
    }
}
```

<p class="callout info">Usage of namespaces makes it clear who is the developer of the project and makes it often easier to find specific project's scope [![image-1659620217781.png](https://vrclibrary.com/wiki/uploads/images/gallery/2022-08/scaled-1680-/image-1659620217781.png)](https://vrclibrary.com/wiki/uploads/images/gallery/2022-08/image-1659620217781.png)</p>

---

### <span style="color: #3598db;">TLDR - Why use namespaces?</span>

- **Define clear scope for your project**
- **Prevent classes and enums from leaking to the default project scope**