What is Assembly?

 Updated on November 02, 2014     VIKRAM     996

Assembly is a .dll (or) .exe. It is a boundary for different classes which are there in an application.

When you compile an application, the CIL code created is stored in an assembly. Assemblies include both executable application files that you can run directly from Windows without the need for any other programs (these have a .exe file extension) and libraries (which have a .dll extension) for use by other applications.

Assembly consists more than one class. Two or more classes present in a assembly then we go for namespace.

Example:

namespace sbo
{
    public class Temp1
    {
        // Members of class Temp1
    }

    public class Temp2
    {
        // Members of class Temp2
    }
}

Namespace is a logical collection of different types. It is a boundary within the assembly.

Question: If we have two classes with same name then what will happen? Look at the following example.

namespace sbo
{
    public class demo
    {
        // Members of class demo
    }

    public class demo
    {
        // Members of class demo
    }
}

When you build this code it says The namespace 'sbo' already contains a definition for 'demo'

Note: So, if two classes are present with same name then those classes will be seperated by namespace.

Example:

namespace sbo
{
    public class demo
    {
        // Members of class demo
    }
}
namespace sbo2
{
    public class demo
    {
        // Members of class demo
    }
}

 

If you enjoyed this post, please like (or) share this article.


Comments