The Fully Qualified Name for a Type Includes the Namespace

If we define a Dog type in the DogLibrary namespace, the fully qualified name for the new type is DogLibrary.Dog.  You can use this full name when working with the type.
1
2
DogLibrary.Dog kirby = new DogLibrary.Dog();
kirby.Bark();
If you’re writing code that exists in the same namespace as a type, you can omit the namespace and just use the short version of the type name.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
namespace DogLibrary
{
    public class Dog
    {
        public string Name { get; set; }
        public int Age { get; set; }
 
        public void Bark()
        {
            Console.WriteLine("WOOOOOF!");
        }
    }
 
    public static class DogFactory
    {
        public static Dog MakeDog(string name, int age)
        {
            // Can just use "Dog" as type name
            Dog d = new Dog();
            d.Name = name;
            d.Age = age;
            return d;
        }
    }
}