...
/Importing a Namespace to Use a Type and Understanding Objects
Importing a Namespace to Use a Type and Understanding Objects
Learn how to import namespaces, create instances, and output descriptions, handle namespace conflicts, and understand inheritance from System.Object.
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:
using Packt.Shared;
Note: Although we could import this namespace globally, it will be clearer to anyone reading this code where we are importing the types we use ...