---
title: "What are Namespaces in C#?"  
description: "What are Namespaces in C#?"  
author: "Anonymous User"  
published: 2019-12-12  
updated: 2019-12-12  
canonical: https://www.mindstick.com/forum/155583/what-are-namespaces-in-c-sharp  
category: ".net"  
tags: [".net", "namespaces"]  
reading_time: 2 minutes  

---

# What are Namespaces in C#?

[Please explain](https://www.mindstick.com/forum/344/hi-rohith-i-am-new-for-mvc-please-explain-how-to-set-implicitly-isauthenticated-true) What are [Namespaces](https://www.mindstick.com/interview/33758/what-is-namespaces-in-c-sharp) in C#?

## Replies

### Reply by Nishi Tiwari

**Namespaces can be defined as organizing the classes**. It provides a way to **keep one set of name separate from other set of name**. Classes defined in one namespaces cannot conflict with other namespaces having same class name. The biggest advantages of using namespaces that class having same name cannot clash or conflict with other class when they defined in different namespaces. It is also called as named group of classes having common features. Namespaces can also include structures, interfaces, and **[delegates](https://www.mindstick.com/forum/155584/give-a-detailed-explanation-of-delegates-in-c-sharp)**. Within namespaces no two classes have the same name

To define namespaces in C# we use keyword namespace followed by namespace name and curly braces containing body of the namespace.

## Syntax

```
Namespace name_of_namespace
{
//classes
//delegates
//structures
//interfaces
}
```

**To access namespace we use dot (.) operator in C#.**

## Syntax

```
Namespace_name.class_name.method_name
```

```
using System;
namespace first_space { class namespace_cl { public void func() {Console.WriteLine("Inside first_space");}}} namespace second_space {
   class namespace_cl {
      public void func() {
         Console.WriteLine("Inside second_space");
      }
   }
}
class TestClass {
   static void Main(string[] args) {
      first_space.namespace_cl fc = new first_space.namespace_cl();
      second_space.namespace_cl sc = new second_space.namespace_cl();
      fc.func();
      sc.func();
      Console.ReadKey();
   }
}
```

## When the above code is compiled and executed, it produces the following result −

```
Inside first_space
Inside second_space
```

![What are Namespaces in C#?](https://www.mindstick.com/mindstickforums/47c10702-11b7-4ef3-9767-5e0e6a71bb99/images/8db3463a-9953-4a50-95c6-bd7908864f72.jpeg)\


---

Original Source: https://www.mindstick.com/forum/155583/what-are-namespaces-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
