Search⌘ K
AI Features

Importing a Namespace to Use a Type and Understanding Objects

Explore how to import namespaces and instantiate objects in C#. Understand the role of System.Object as the base class for all types and learn to use aliases to avoid namespace conflicts. This lesson builds a foundation for object-oriented programming in C#.

Let’s look at the essentials of class interaction and namespaces in C#. We’ll learn the namespace imports and object instantiation to aliases, and inheritance will be demystified. Brace ourselves for exploring core programming concepts that will set the stage for a deeper understanding of C# development.

Importing a namespace to use a type

Now, we are ready to write statements to work with the Person class:

Step 1: In the PeopleApp project/folder, in Program.cs file, delete the existing statements, and then add statements to import the namespace for our Person class, as shown in the following code:

C#
using Packt.Shared;

...