Tuesday, July 16, 2013

Namespaces and Assemblies

It is best to always define your classes in a namespace, that way if other programmers decide to use your assembly in their program and they use a class with the same name as one of your classes, they can still coexist under different namespaces.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Etcetera;
using System.BlaBlaBla;

When invoking a template, Using Directives are automatically added, bringing certain classes into the scope of your program.

Here is what a generic console project will look like:

namespace TheNameOfMyProgram
{//All this is the of the namespace of my program
    class Program
    {//I am creating a class called program that is delimited in these curly braces.
        static void Main(string[] args)
        {//This is the main function & entry point

        }
       }
}


Assemblies are referenced in the the references folder of the solution explorer. You can add and delete them by R+Clicking.

No comments:

Post a Comment