Tuesday, March 16, 2010

C# Program Architecture

A C# program may contain one or more files. Any files can contain any of the following elements: -
•    Directives
•    Namespaces (which can contain all other elements and namespaces)
•    Classes
•    Structs (structures)
•    Interfaces
•    Delegates
•    Enums(enumerations)
•    Function methods (such as methods, properties, indexes, and so forth)
If the program consists of more than one file, only one Main method is required in one of the files.
Example: -
using System;    // Directive
namespace Namespace1    //Namespace
{
    class Class1    //Class
    {
    }
    struct     Struct1    //Struct
    {
    }
    interface Interface1    //Interface
    {
    }
    delegate int Delegate1();    //Delegate
    enum Enum1    //Enumeration
    {
    {

    namespace Namespace2    //Namespace
    {
    }
    class Class2    //Class
    {
        static void Main() //The Main method
        {
        }
    }

No comments:

Post a Comment