From the course: C# Essential Training 1: Types and Control Flow

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Using namespaces to organize code

Using namespaces to organize code

- [Instructor] Now that we've started creating types and using types, it's important to understand how namespace has come into play. All .NET types, belong to some sort of namespace. If you take a look here at our Constants.cs file at the top... I'll just collapse my class definition here. You can see that we have a namespace LinkedIn.Essentials wrapping that class definition. And this is the traditional way that you would define the namespace that your types are contained in. In the middle file are defining types where we have our person, and our employee and manager. Notice at the top, we have namespace, LinkedIn.Essentials, and a semi-colon. So, the real difference here is the first example of top. You wrap the classes or types within the namespace. And in the second in the middle, you simply declare the namespace at the top with the semi-colon. That one, as you can see from the comment is new in C# 10. And it essentially came about because most people define one type per file. And…

Contents